Gin: Question about middleware

Created on 27 Aug 2018  路  4Comments  路  Source: gin-gonic/gin

Question

May I setup a middleware for certain api?

  • description
    For example, I hve 2 apis in the same group, one requires login first, one not.
    So can I use middleware for only one api in that group?
  • gin version (or commit ref):
    1.3.0

Most helpful comment

All 4 comments

As @syssam pointed, thanks! closing

It's my fault for not reading the guide carefully. Thanks so much!

// Per route middleware, you can add as many as you desire.
r.GET("/benchmark", MyBenchLogger(), benchEndpoint)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

sofish picture sofish  路  3Comments

iiinsomnia picture iiinsomnia  路  3Comments

gplume picture gplume  路  3Comments

CodingPapi picture CodingPapi  路  3Comments

ghost picture ghost  路  3Comments