@@ -15,22 +15,22 @@ type DiffModelConfig struct {
1515	Action    string  `mapstructure:"action" json:"action,omitempty" gorm:"column:action" bson:"action,omitempty" dynamodbav:"action,omitempty" firestore:"action,omitempty"` 
1616}
1717type  DiffHandler  struct  {
18- 	DiffService   DiffService 
19- 	Keys          []string 
20- 	ModelType     reflect.Type 
21- 	Error         func (context.Context , string )
22- 	Indexes       map [string ]int 
23- 	Offset        int 
24- 	Log           func (ctx  context.Context , resource  string , action  string , success  bool , desc  string ) error 
25- 	Resource      string 
26- 	Action        string 
27- 	Config        * DiffModelConfig 
18+ 	GetDiff     func ( ctx  context. Context ,  id   interface {}) ( * DiffModel ,  error ) 
19+ 	Keys       []string 
20+ 	ModelType  reflect.Type 
21+ 	Error      func (context.Context , string )
22+ 	Indexes    map [string ]int 
23+ 	Offset     int 
24+ 	Log        func (ctx  context.Context , resource  string , action  string , success  bool , desc  string ) error 
25+ 	Resource   string 
26+ 	Action     string 
27+ 	Config     * DiffModelConfig 
2828}
2929
30- func  NewDiffHandler (diffService   DiffService , modelType  reflect.Type , logError  func (context.Context , string ), config  * DiffModelConfig , writeLog  func (context.Context , string , string , bool , string ) error , options  ... int ) * DiffHandler  {
31- 	return  NewDiffHandlerWithKeys (diffService , nil , modelType , logError , config , writeLog , options ... )
30+ func  NewDiffHandler (diff   func (context. Context ,  interface {}) ( * DiffModel ,  error ) , modelType  reflect.Type , logError  func (context.Context , string ), config  * DiffModelConfig , writeLog  func (context.Context , string , string , bool , string ) error , options  ... int ) * DiffHandler  {
31+ 	return  NewDiffHandlerWithKeys (diff , nil , modelType , logError , config , writeLog , options ... )
3232}
33- func  NewDiffHandlerWithKeys (diffService   DiffService , keys  []string , modelType  reflect.Type , logError  func (context.Context , string ), config  * DiffModelConfig , writeLog  func (context.Context , string , string , bool , string ) error , options  ... int ) * DiffHandler  {
33+ func  NewDiffHandlerWithKeys (diff   func (context. Context ,  interface {}) ( * DiffModel ,  error ) , keys  []string , modelType  reflect.Type , logError  func (context.Context , string ), config  * DiffModelConfig , writeLog  func (context.Context , string , string , bool , string ) error , options  ... int ) * DiffHandler  {
3434	offset  :=  1 
3535	if  len (options ) >  0  {
3636		offset  =  options [0 ]
@@ -50,15 +50,15 @@ func NewDiffHandlerWithKeys(diffService DiffService, keys []string, modelType re
5050	if  len (action ) ==  0  {
5151		action  =  "diff" 
5252	}
53- 	return  & DiffHandler {Log : writeLog , DiffService :  diffService , ModelType : modelType , Keys : keys , Indexes : indexes , Resource : resource , Offset : offset , Config : config , Error : logError }
53+ 	return  & DiffHandler {Log : writeLog , GetDiff :  diff , ModelType : modelType , Keys : keys , Indexes : indexes , Resource : resource , Offset : offset , Config : config , Error : logError }
5454}
5555
5656func  (c  * DiffHandler ) Diff (w  http.ResponseWriter , r  * http.Request ) {
5757	id , err  :=  buildId (r , c .ModelType , c .Keys , c .Indexes , c .Offset )
5858	if  err  !=  nil  {
5959		http .Error (w , err .Error (), http .StatusBadRequest )
6060	} else  {
61- 		result , err  :=  c .DiffService . Diff (r .Context (), id )
61+ 		result , err  :=  c .GetDiff (r .Context (), id )
6262		if  err  !=  nil  {
6363			handleError (w , r , http .StatusInternalServerError , internalServerError , c .Error , c .Resource , c .Action , err , c .Log )
6464		} else  {
0 commit comments