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

     1  package middleware
     2  
     3  import (
     4  	"context"
     5  
     6  	confrate "github.com/machinefi/w3bstream/pkg/depends/conf/rate_limit"
     7  	"github.com/machinefi/w3bstream/pkg/depends/kit/logr"
     8  )
     9  
    10  type EventReqRateLimit struct{}
    11  
    12  func (r *EventReqRateLimit) Output(ctx context.Context) (interface{}, error) {
    13  	ctx, l := logr.Start(ctx, "api.mw.EventReqRateLimit")
    14  	defer l.End()
    15  
    16  	rl := confrate.MustRateLimitKeyFromContext(ctx)
    17  
    18  	rl.Limiter.Take()
    19  	return nil, nil
    20  }