gorilla / mux

Package gorilla/mux is a powerful HTTP router and URL matcher for building Go web servers with 🦍
https://gorilla.github.io
BSD 3-Clause "New" or "Revised" License
20.86k stars 1.85k forks source link

URL template for path #213

Closed huytn closed 7 years ago

huytn commented 7 years ago

I'm building a RESTful file server which supports listing a specified directory, and download file. To build such url template I need put dir path or file path in url. I found the following things from [RFC 6570](https://tools.ietf.org/html/rfc6570#page-5): {+path}/here /foo/bar/here In my case: rtr.HandleFunc("/v1/{+path}", List_files).Methods("GET") Will list dir or download file. Is there anyway to do this?

elithrar commented 7 years ago

Have your handler check for the presence of a file, and if it doesn't exist, serve the dir listing? Or 404?

On Tue, Jan 3, 2017 at 8:15 PM huytn notifications@github.com wrote:

I'm building a RESTful file server which supports listing a specified directory, and download file. To build such url template I need put dir path or file path in url. I found the following things from RFC 6570:

{+path}/here /foo/bar/here

In my case:

rtr.HandleFunc("/v1/{+path}", List_files).Methods("GET")

Will list dir or download file.

Is there anyway to do this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/gorilla/mux/issues/213, or mute the thread https://github.com/notifications/unsubscribe-auth/AABIcHpKCPSLwBXgRFmGO9HwPrSYRSKlks5rOxz2gaJpZM4LaRsY .

elithrar commented 7 years ago

Closing due to inactivity.

huytn commented 7 years ago

I did, many thanks.