Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose mainServer in the fashion of http.DefaultServeMux #156

Open
justinas opened this issue Aug 28, 2013 · 1 comment
Open

Expose mainServer in the fashion of http.DefaultServeMux #156

justinas opened this issue Aug 28, 2013 · 1 comment

Comments

@justinas
Copy link

At the moment, if you've written a code like

web.Get("/", handler)
web.Get("/somethingelse", anotherHandler)
// etc.

There is no way (AFAIK) to get the http.Handler behind this (in case you'd like to wrap it in some middleware, etc.). All you can do is create a new Server and then rewrite the code to use it (rather than the module-level functions that work on the main server).

I don't think there would be any trouble with exposing mainServer publicly, kind of like http.DefaultServeMux is exposed (feel free to correct me). If you don't care about an extra variable lying around, then it's a one-line fix:

var MainServer = mainServer

(otherwise you'd have to s/mainServer/MainServer everywhere).

I'd like to hear some feedback on this. Would anyone else find this useful? Is this more complex than I think and there'd be some weird problems?

@phpfs
Copy link

phpfs commented Jun 6, 2018

Connected to #214 - if it was possible to access the handler directly, cors could be handled by e.g. https://github.com/rs/cors :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants