github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/cmd/srv-applet-mgr/apis/strategy/put.go (about) 1 package strategy 2 3 import ( 4 "context" 5 6 "github.com/machinefi/w3bstream/cmd/srv-applet-mgr/apis/middleware" 7 "github.com/machinefi/w3bstream/pkg/depends/base/types" 8 "github.com/machinefi/w3bstream/pkg/depends/kit/httptransport/httpx" 9 "github.com/machinefi/w3bstream/pkg/modules/strategy" 10 ) 11 12 type UpdateStrategy struct { 13 httpx.MethodPut 14 StrategyID types.SFID `in:"path" name:"strategyID"` 15 strategy.UpdateReq `in:"body"` 16 } 17 18 func (r *UpdateStrategy) Path() string { 19 return "/:strategyID" 20 } 21 22 func (r *UpdateStrategy) Output(ctx context.Context) (interface{}, error) { 23 ctx, err := middleware.MustCurrentAccountFromContext(ctx). 24 WithStrategyBySFID(ctx, r.StrategyID) 25 if err != nil { 26 return nil, err 27 } 28 return nil, strategy.Update(ctx, r.StrategyID, &r.UpdateReq) 29 }