MCPcopy Index your code
hub / github.com/rilldata/rill / checkGithubRateLimit

Method checkGithubRateLimit

admin/server/github.go:1025–1039  ·  view source on GitHub ↗
(route string)

Source from the content-addressed store, hash-verified

1023}
1024
1025func (s *Server) checkGithubRateLimit(route string) middleware.CheckFunc {
1026 return func(req *http.Request) error {
1027 claims := auth.GetClaims(req.Context())
1028 if claims == nil || claims.OwnerType() == auth.OwnerTypeAnon {
1029 limitKey := ratelimit.AnonLimitKey(route, observability.HTTPPeer(req))
1030 if err := s.limiter.Limit(req.Context(), limitKey, ratelimit.Sensitive); err != nil {
1031 if errors.As(err, &ratelimit.QuotaExceededError{}) {
1032 return httputil.Error(http.StatusTooManyRequests, err)
1033 }
1034 return err
1035 }
1036 }
1037 return nil
1038 }
1039}
1040
1041func (s *Server) userAccessToken(ctx context.Context, user *database.User) (string, error) {
1042 if user.GithubTokenExpiresOn != nil && user.GithubTokenExpiresOn.After(time.Now().Add(5*time.Minute)) {

Callers 1

Calls 7

GetClaimsFunction · 0.92
AnonLimitKeyFunction · 0.92
HTTPPeerFunction · 0.92
ErrorFunction · 0.92
ContextMethod · 0.65
OwnerTypeMethod · 0.65
LimitMethod · 0.65

Tested by

no test coverage detected