AnswerBun.com

Gorilla Mux Router GET URL with multiple query param only matches if called by all query params

Stack Overflow Asked by Sumit Arora on December 4, 2020

Below is a snapshot of a HTTP Get Call while using Gorilla Mux Router:

usersAPIs.HandleFunc("/users",
    middleware.WrapperHandler(th.List)).
    Queries("email", "{email}").
    Queries("order_by", "{order_by}").
    Queries("order_type", "{order_type}").
    Queries("page", "{page}").
    Queries("limit", "{limit}").
    Methods("GET")

Now when GET call happens with all query params e.g.

http://localhost:xxxx/accounts/users?email=a&page=1&limit=4&order_by=a&order_type=b 

then the gorilla mux router matches the pattern and takes it to the handler.

But when called like with fewer parameters e.g.

http://localhost:xxxx/accounts/users?email=a&page=1

then it says e.g. 404 not found means Resource path not mapped.

Questions :

#1. What has been missed here, is Go Gorilla Mux Router need all query params?

#2. What to be done If the GET query can come with zero or more parameters? e.g.

http://localhost:xxxx/accounts/users?email=a&page=1 

or

http://localhost:xxxx/accounts/users?page=1 

Add your own answers!

Related Questions

How to convert hour into seconds?

1  Asked on December 13, 2021

     

How to send JSON body in GET request golang?

2  Asked on December 13, 2021

       

Does a set in node.js reset if you restart a program?

1  Asked on December 13, 2021 by h-rashid

   

How to trigger button with html href?

2  Asked on December 13, 2021 by dzwash

     

Taking input of unknown size of array

1  Asked on December 13, 2021 by subhradwip-ghosh

         

Reduce method not clear

2  Asked on December 13, 2021 by dario-k

     

Matching + character with Java Regex

1  Asked on December 13, 2021 by felix-darke

   

Python nested classes: self is not defined

1  Asked on December 13, 2021 by cminusminus

     

Ask a Question

Get help from others!

© 2022 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP, SolveDir