From 76cbe25df038b14e403ec56b5b42cc060a1dbcdc Mon Sep 17 00:00:00 2001 From: xun Date: Wed, 13 Mar 2024 14:29:53 +0800 Subject: [PATCH] Clean up comments for better readability and clarity --- api/v1/oauth_server.go | 11 ----------- middleware/request_limiter.go | 6 +----- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/api/v1/oauth_server.go b/api/v1/oauth_server.go index 5bbb4b6..9ff876c 100644 --- a/api/v1/oauth_server.go +++ b/api/v1/oauth_server.go @@ -223,17 +223,6 @@ func Authorize(c *gin.Context) { // Redirect user to login page if user not login or // Get code directly if user has logged in err := srv.HandleAuthorizeRequest(w, r) - // clients, _ := srv.Manager.GetClient(c, r.Form.Get("client_id")) - // var item ClientStoreItem - // if err := clientAdapter.SelectOne(c, &item, fmt.Sprintf("SELECT * FROM %s WHERE id = $1", "oauth2_clients"), r.Form.Get("client_id")); err != nil { - // log.Log.Errorf("\n----DEBUG----: %s\n", err.Error()) - // log.Log.Printf("\nau :: client: %s\n", item) - // log.Log.Printf("\nau :: client_id: %s\n", r.Form.Get("client_id")) - // log.Log.Errorf("\n----DEBUG----: %s\n", err.Error()) - // return - // } - // log.Log.Printf("\nau :: client: %s\n", clients) - // log.Log.Printf("\nau :: client_id: %s\n", r.Form.Get("client_id")) if err != nil { c.JSON(http.StatusInternalServerError, result.Failed(result.InternalErr.Wrap(err))) return diff --git a/middleware/request_limiter.go b/middleware/request_limiter.go index 4c8139c..8597919 100644 --- a/middleware/request_limiter.go +++ b/middleware/request_limiter.go @@ -9,11 +9,7 @@ import ( "github.com/gin-gonic/gin" ) -func HelloHandler(w http.ResponseWriter, req *http.Request) { - w.Write([]byte("Hello, World!")) -} - -// Custom limiter +// Example: RequestRateLimiter(3, time.Minute) represents 3 requests per minute func RequestRateLimiter(maxRequests int64, period time.Duration) gin.HandlerFunc { rate := float64(maxRequests) / float64(period.Seconds()) limiter := tollbooth.NewLimiter(rate, nil)