github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/cmd/srv-applet-mgr/apis/strategy/pos.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/kit/httptransport/httpx"
     8  	"github.com/machinefi/w3bstream/pkg/modules/strategy"
     9  )
    10  
    11  type CreateStrategy struct {
    12  	httpx.MethodPost
    13  	strategy.CreateReq `in:"body"`
    14  }
    15  
    16  func (r *CreateStrategy) Output(ctx context.Context) (interface{}, error) {
    17  	ctx, err := middleware.MustCurrentAccountFromContext(ctx).
    18  		WithAppletContextBySFID(ctx, r.AppletID)
    19  	if err != nil {
    20  		return nil, err
    21  	}
    22  	return strategy.Create(ctx, &r.CreateReq)
    23  }