You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: filter.go
    path of file: ./repos/erda/internal/apps/ai-proxy/filters/rate-limit
    
    the code of the file until where you have to start completion: // Copyright (c) 2021 Terminus, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
    
func (f *RateLimiter) OnRequest(ctx context.Context, w http.ResponseWriter, infor reverseproxy.HttpInfor) (signal reverseproxy.Signal, err error) {
	var l = ctx.Value(reverseproxy.LoggerCtxKey{}).(logs.Logger)
	l.Sub(Name)

	// only limit token rate now
	token, isTokenInvoke := isClientTokenInvoke(infor)
	if !isTokenInvoke {
		return reverseproxy.Continue, nil
	}

	limiter := tokenLimiter.GetLimiter(token)
	if !limiter.Allow() {
		err := fmt.Errorf("too many requests for token rate limit, token: %s", token)
		l.Warn(err)
		http.Error(w, "too many requests for token rate limit", http.StatusTooManyRequests)
		// record to audit
		auditID, ok := ctxhelper.GetAuditID(ctx)
		if ok {
			_, err := ctxhelper.MustGetDBClient(ctx).AuditClient().SetFilterErrorAudit(ctx, &auditpb.AuditUpdateRequestWhenFilterError{
				AuditId:     auditID,
				FilterName:  Name,
				FilterError: err.Error(),
			})
			if err != nil {
				l := ctxhelper.GetLogger(ctx)
				l.Errorf("failed to update audit when rate limited, audit id: %s, err: %v", auditID, err)
			}
		}
		return reverseproxy.Intercept, nil
	}
	l.Debugf("pass token rate limit, token: %s", token)

	return reverseproxy.Continue, nil
}