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

kekemuyu picture kekemuyu  路  3Comments

mastrolinux picture mastrolinux  路  3Comments

cxk280 picture cxk280  路  3Comments

ghost picture ghost  路  3Comments

boneq picture boneq  路  3Comments