Gin: How to create router, that will match any request?

Created on 21 Dec 2017  路  2Comments  路  Source: gin-gonic/gin

Hi,

I need to handle all requests in one route.
For example, I have website with many urls, smth like /, /users, /users/list ... etc
I want to use only one route to handle all this, something like
r.Any("*", handle) and all my requests need to handle by this route.
How can I make it?

Thanks for help

question

Most helpful comment

router.Any("/*proxyPath", handler)

Access path from handlers with:

func someHandler(c *gin.Context) {
    c.Param("proxyPath")
}

All 2 comments

I think you need to use middleware instead of routing

router.Any("/*proxyPath", handler)

Access path from handlers with:

func someHandler(c *gin.Context) {
    c.Param("proxyPath")
}
Was this page helpful?
0 / 5 - 0 ratings

Related issues

boneq picture boneq  路  3Comments

nxvl picture nxvl  路  3Comments

lilee picture lilee  路  3Comments

ghost picture ghost  路  3Comments

gplume picture gplume  路  3Comments