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