Path Prefix

Path Prefix is a wildcard for matching after a defined path. The general use case is when we serve files from our static folder and all URLs should be served as-is. From the official Mux documentation, we can use this for serving static files. This is the Mux version of the static file server that we created in the preceding program using httprouter:

r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", http.FileServer(http.Dir("/tmp/static"))))

This can serve all kinds of files in the directory:

http://localhost:8000/static/js/jquery.min.js 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.138.178