feat: linting
This commit is contained in:
@ -50,10 +50,7 @@ func WithAuthRedirect(next http.Handler, key string) http.Handler {
|
||||
}
|
||||
next.ServeHTTP(w, r)
|
||||
|
||||
case "_app":
|
||||
next.ServeHTTP(w, r)
|
||||
|
||||
case "favicon.png":
|
||||
case "_app", "favicon.png", "icon.png":
|
||||
next.ServeHTTP(w, r)
|
||||
|
||||
default:
|
||||
@ -69,17 +66,17 @@ func WithAuthRedirect(next http.Handler, key string) http.Handler {
|
||||
})
|
||||
}
|
||||
|
||||
type authInterceptor struct {
|
||||
type AuthInterceptor struct {
|
||||
key string
|
||||
}
|
||||
|
||||
func NewAuthInterceptor(key string) *authInterceptor {
|
||||
return &authInterceptor{
|
||||
func NewAuthInterceptor(key string) *AuthInterceptor {
|
||||
return &AuthInterceptor{
|
||||
key: key,
|
||||
}
|
||||
}
|
||||
|
||||
func (i *authInterceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc {
|
||||
func (i *AuthInterceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc {
|
||||
// Same as previous UnaryInterceptorFunc.
|
||||
return connect.UnaryFunc(func(
|
||||
ctx context.Context,
|
||||
@ -123,7 +120,7 @@ func (i *authInterceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc {
|
||||
})
|
||||
}
|
||||
|
||||
func (*authInterceptor) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc {
|
||||
func (*AuthInterceptor) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc {
|
||||
return connect.StreamingClientFunc(func(
|
||||
ctx context.Context,
|
||||
spec connect.Spec,
|
||||
@ -132,7 +129,7 @@ func (*authInterceptor) WrapStreamingClient(next connect.StreamingClientFunc) co
|
||||
})
|
||||
}
|
||||
|
||||
func (i *authInterceptor) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc {
|
||||
func (i *AuthInterceptor) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc {
|
||||
return connect.StreamingHandlerFunc(func(
|
||||
ctx context.Context,
|
||||
conn connect.StreamingHandlerConn,
|
||||
|
@ -15,14 +15,14 @@ type visitor struct {
|
||||
lastSeen time.Time
|
||||
}
|
||||
|
||||
type ratelimitInterceptor struct {
|
||||
type RatelimitInterceptor struct {
|
||||
key string
|
||||
visitors map[string]*visitor
|
||||
mu sync.Mutex
|
||||
}
|
||||
|
||||
func NewRateLimitInterceptor(key string) *ratelimitInterceptor {
|
||||
rl := &ratelimitInterceptor{
|
||||
func NewRateLimitInterceptor(key string) *RatelimitInterceptor {
|
||||
rl := &RatelimitInterceptor{
|
||||
key: key,
|
||||
visitors: make(map[string]*visitor),
|
||||
mu: sync.Mutex{},
|
||||
@ -33,7 +33,7 @@ func NewRateLimitInterceptor(key string) *ratelimitInterceptor {
|
||||
return rl
|
||||
}
|
||||
|
||||
func (i *ratelimitInterceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc {
|
||||
func (i *RatelimitInterceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFunc {
|
||||
// Same as previous UnaryInterceptorFunc.
|
||||
return connect.UnaryFunc(func(
|
||||
ctx context.Context,
|
||||
@ -54,7 +54,7 @@ func (i *ratelimitInterceptor) WrapUnary(next connect.UnaryFunc) connect.UnaryFu
|
||||
})
|
||||
}
|
||||
|
||||
func (*ratelimitInterceptor) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc {
|
||||
func (*RatelimitInterceptor) WrapStreamingClient(next connect.StreamingClientFunc) connect.StreamingClientFunc {
|
||||
return connect.StreamingClientFunc(func(
|
||||
ctx context.Context,
|
||||
spec connect.Spec,
|
||||
@ -63,7 +63,7 @@ func (*ratelimitInterceptor) WrapStreamingClient(next connect.StreamingClientFun
|
||||
})
|
||||
}
|
||||
|
||||
func (i *ratelimitInterceptor) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc {
|
||||
func (i *RatelimitInterceptor) WrapStreamingHandler(next connect.StreamingHandlerFunc) connect.StreamingHandlerFunc {
|
||||
return connect.StreamingHandlerFunc(func(
|
||||
ctx context.Context,
|
||||
conn connect.StreamingHandlerConn,
|
||||
@ -78,7 +78,7 @@ func (i *ratelimitInterceptor) WrapStreamingHandler(next connect.StreamingHandle
|
||||
})
|
||||
}
|
||||
|
||||
func (i *ratelimitInterceptor) getVisitor(userAgent string) *rate.Limiter {
|
||||
func (i *RatelimitInterceptor) getVisitor(userAgent string) *rate.Limiter {
|
||||
i.mu.Lock()
|
||||
defer i.mu.Unlock()
|
||||
|
||||
@ -97,7 +97,7 @@ func (i *ratelimitInterceptor) getVisitor(userAgent string) *rate.Limiter {
|
||||
|
||||
// Every minute check the map for visitors that haven't been seen for
|
||||
// more than 3 minutes and delete the entries.
|
||||
func (i *ratelimitInterceptor) cleanupVisitors() {
|
||||
func (i *RatelimitInterceptor) cleanupVisitors() {
|
||||
for {
|
||||
time.Sleep(time.Minute)
|
||||
|
||||
|
Reference in New Issue
Block a user