Home > Mobile >  Is there any way to make two GET query parameters point to two different routes (handler functions)
Is there any way to make two GET query parameters point to two different routes (handler functions)

Time:01-01

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?

CodePudding user response:

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

No.

or with "basic" GO?

No.

  • Related