klen/http-router

Doesn't seem to handle query string params

WilliamStam opened this issue · 1 comments

sorry if this is obvious, didnt see anything in the docs but at this point im probably totaly blind.

if the path contains a ? it never matches. /test is fine but /test?t=123 is not. (i think. i just cant get it to work :()

thanks for the effort on the lib!

edit: im sure using the regex option would work but thats not really something that could be considered "expected behavior".
if setting up a route with

router = Router()
@router.route("/test")
def r():
    print("woof")

in hindsight i probably can do this myself before callign the router part tho. so its not a "bug" its probably an enhancement request then :P

and incase anyone comes along and they dont know where to start with something like this... (still working on it but heres a starting point) - using the python http.server

class Web(BaseHTTPRequestHandler):

    def do_HEAD( self ):
        return

    def do_GET( self ):
        print(self)
        route_path = self.path
        route_path = route_path.split('?')[0]
        try:
            route = app.routes(route_path,self.command)
        except NotFound:
            print("NOT FOUND")
            route = app.routes("/404",self.command)
        except MethodNotAllowed:
            print("Method not allowed")
        else:
            print("we good")

        print(route.target())