-
Notifications
You must be signed in to change notification settings - Fork 19
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
Standard library routing #151
Conversation
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.
Some suggestions for refinements in this or further PRs, but nothing that should block this from merging
} | ||
|
||
serveFromFS, err := strconv.ParseBool(os.Getenv("SERVE_FROM_FS")) |
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.
Consider lifting this parsing of the env vars out of the server and have it get passed in as an option in NewServer
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.
I'll do this neatly in its own PR so I don't have to look for it later
|
||
//TODO: Add sample logs and metrics | ||
writer.WriteHeader(http.StatusOK) | ||
_, isCI := os.LookupEnv("CI") |
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.
Ditto for this env var, maybe an "autoOpenBrowser" option, or have the app code itself open the browser instead of the server
Definitely not necessary to change in this PR though
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.
Ditto this.
writer.WriteHeader(http.StatusInternalServerError) | ||
return | ||
log.Fatal(err) |
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.
Consider instrumentation / logging instead of immediately failing. We could create a single function to handle errors that cannot be recovered from so they are consistent.
return s.server.Close() | ||
} | ||
|
||
func (s *Server) Handler(serveFromFS bool) http.Handler { |
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.
serveFromFS
should probably also be an option passed into NewServer
.
Naively, I would expect the routes to be set up as part of NewServer
not require a further call
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.
I'm not sure where else to handle this one, since serveFromFS is only used during development. I'll figure it out in the same PR as the others though.
server.go
to use standard routing instead of gorilla/mux (thank you for your service)store.go
andqueries.go