github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/cmd/srv-applet-mgr/apis/publisher/put.go (about) 1 package publisher 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/publisher" 9 "github.com/machinefi/w3bstream/pkg/types" 10 ) 11 12 // Update Publisher by Publisher ID 13 type UpdatePublisher struct { 14 httpx.MethodPut 15 PublisherID types.SFID `in:"path" name:"publisherID"` 16 publisher.UpdateReq `in:"body"` 17 } 18 19 func (r *UpdatePublisher) Path() string { return "/:publisherID" } 20 21 func (r *UpdatePublisher) Output(ctx context.Context) (interface{}, error) { 22 ctx, err := middleware.MustCurrentAccountFromContext(ctx). 23 WithPublisherBySFID(ctx, r.PublisherID) 24 if err != nil { 25 return nil, err 26 } 27 r.UpdateReq.PublisherID = types.MustPublisherFromContext(ctx).PublisherID 28 29 return nil, publisher.Update(ctx, &r.UpdateReq) 30 }