Mux.jl icon indicating copy to clipboard operation
Mux.jl copied to clipboard

How do I match the whole path?

Open shashi opened this issue 7 years ago • 2 comments

page("/foo/:key", server)

only matches one word keys like foo/bar. How do I match /foo/bar/baz?

shashi avatar Jan 02 '18 04:01 shashi

For posterity:

There's not a function for that. You would have to write your own middleware to do so, but that's not hard :)

You could fairly easily come up with some syntax and write custom middleware with the stuff in src/routing.jl.

Alternatively, you can write something custom that handles paths however you like:

branch(req -> startswith(req[:path], "/foo/"),
    req -> respond("The rest of the path is $(req[:path][5:end])")
)

cmcaine avatar Dec 06 '20 08:12 cmcaine

Oh, lol, you probably wrote this and know that well. I'll leave my comment in case users have the same question.

cmcaine avatar Dec 06 '20 08:12 cmcaine