github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/cmd/srv-applet-mgr/apis/wasmlog/del.go (about)

     1  package wasmlog
     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/wasmlog"
     9  	"github.com/machinefi/w3bstream/pkg/types"
    10  )
    11  
    12  type RemoveWasmLogByInstanceID struct {
    13  	httpx.MethodDelete
    14  	InstanceID types.SFID `in:"path" name:"instanceID"`
    15  }
    16  
    17  func (r *RemoveWasmLogByInstanceID) Path() string { return "/:instanceID" }
    18  
    19  func (r *RemoveWasmLogByInstanceID) Output(ctx context.Context) (interface{}, error) {
    20  	ctx, err := middleware.MustCurrentAccountFromContext(ctx).
    21  		WithInstanceContextBySFID(ctx, r.InstanceID)
    22  	if err != nil {
    23  		return nil, err
    24  	}
    25  	return nil, wasmlog.Remove(ctx, &wasmlog.CondArgs{InstanceID: r.InstanceID})
    26  }