Search code examples
gogo-gin

Is there any way to make two GET query parameters point to two different routes (handler functions) in Golang or GIN?


I am trying to do the following:

/car?color= -> first route (endpoint) and first handler function

/car?brand= -> second route (endpoint) and second handler function

/car?type= -> third route (endpoint) and third handler function

...

I tried the following in GIN:

server.GET("/car?color=", carColorHandlerFunction)
server.GET("/car?brand=", carBrandHandlerFunction)
server.GET("/car?type=", carTypeHandlerFunction)

Also tried:

server.GET("/car?color=:carColor", carColorHandlerFunction)
server.GET("/car?brand=:carBrand", carBrandHandlerFunction)
server.GET("/car?type=:carType", carTypeHandlerFunction)

Unfortunately, it does not work. It does not recognize these routes.

Is there a way to make it work and how to make it with a GIN or with "basic" GO?


Solution

  • Is there a way to make it work and how to make it with a GIN

    No.

    or with "basic" GO?

    No.