-
Notifications
You must be signed in to change notification settings - Fork 139
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
Refactor handlers: make Config not global #67
Conversation
This already looks very good, thanks! I've got a few comments:
|
Great idea -- I'll get on that!
I can do that. It probably "feels wrong" because it's named Config, but it might as well be named |
I went ahead and renamed Config to Server, and used a single instance of it in main -- I do like this better. :) |
I know you've been busy @fd0, so just a friendly ping in case this got lost in all the shuffle. :) |
Any other changes you need for this? I've been using this for some time and it is working well for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is so much better, thank you! It indeed bugged me because it was named Config
. Server
is a great choice.
Refactor handlers: make Config not global
Yay!! Thanks! |
In June 2018, dependency rest-server[1] cleaned up its API a little[2], breaking the Caddy restic plugin build in the process. Attempting to build Caddy with the plugin leads to the following errors: ``` build/src/github.com/restic/caddy/setup.go:24:4: undefined: restserver.Config build/src/github.com/restic/caddy/setup.go:40:19: undefined: restserver.NewMux ``` This commit applies the upstream API changes to fix the errors. [1]: https://github.com/restic/rest-server [2]: restic/rest-server#67
In June 2018, dependency rest-server[1] cleaned up its API a little[2], breaking the Caddy restic plugin build in the process. Attempting to build Caddy with the plugin leads to the following errors: ``` build/src/github.com/restic/caddy/setup.go:24:4: undefined: restserver.Config build/src/github.com/restic/caddy/setup.go:40:19: undefined: restserver.NewMux ``` This commit applies the upstream API changes to fix the errors. [1]: https://github.com/restic/rest-server [2]: restic/rest-server#67
In June 2018, dependency rest-server[1] cleaned up its API a little[2], breaking the Caddy restic plugin build in the process. Attempting to build Caddy with the plugin leads to the following errors: ``` build/src/github.com/restic/caddy/setup.go:24:4: undefined: restserver.Config build/src/github.com/restic/caddy/setup.go:40:19: undefined: restserver.NewMux ``` This commit applies the upstream API changes to fix the errors. [1]: https://github.com/restic/rest-server [2]: restic/rest-server#67
I know this diff looks huge, but it's actually pretty simple: instead of a global value named
Config
, the identifier namedConfig
is now astruct
type. Instead of having all sorts of global configuration, we confine it to that struct... and attach the handlers as methods on the struct.It's a lot cleaner, in that CLI options are confined to
main
and the main() function just builds aConfig
struct like any other user of the library would.This makes it possible to use the
restserver
package as a library.The default configuration is still preserved.
Closes #66
/cc @rawtaz