Closed ghost closed 4 years ago
I am only load shedding the app side of things. My guess is http.Handle is adding a route to the default router (http.DefaultServerMux). If you want load shedding, you want to bind that to app.Handle. Assuming you want the /files
route on port 80, you will really need a new http.Server bound to that port. Look at main.go:205 for more details.
When I check web.go and see the Handler only for api format, is that possible to add support for fileSystem?
// A type that handles an http request within our own little mini framework.
type Handler func(ctx context.Context, w http.ResponseWriter, r *http.Request, params map[string]string) error
// A type that serve static files within our own little mini framework.
type Handler func(ctx context.Context, path string, root http.FileSystem) error
I apologize for not being clear in my last message :(
Look at this issue and someone has provided a link where they are using the file system. https://github.com/ardanlabs/service/issues/113
Yes, it's nice example for a new http.Handler create and all I need in this project. But later I think it will be better to wrap the Handler to support static files because of httptreemux (or httprouter) also do it.
You an look here for what you were requesting.
https://github.com/dgraph-io/travel/blob/master/cmd/travel-ui/internal/handlers/routes.go
If I add the fileSystem with http.Handle in the routes, is it autoClosed when shutdown the API?