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

use new response error for client's error encoder #40

Merged
merged 5 commits into from
Jan 19, 2017
Merged

use new response error for client's error encoder #40

merged 5 commits into from
Jan 19, 2017

Conversation

xh3b4sd
Copy link
Contributor

@xh3b4sd xh3b4sd commented Jan 18, 2017

No description provided.

@xh3b4sd xh3b4sd self-assigned this Jan 18, 2017
@@ -93,6 +93,7 @@ func (c *command) Execute(cmd *cobra.Command, args []string) {
serverConfig.ListenAddress = Flags.Server.Listen.Address
serverConfig.Logger = c.logger
serverConfig.RequestFuncs = customServer.RequestFuncs()
serverConfig.Router = customServer.Router()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The router is now configurable which makes it easy to provide seamless migration paths towards microkit. This was rather easy to accomplish at the end. Back then I struggled conceptually.


// Settings.
ListenAddress: "http://127.0.0.1:8080",
ListenAddress: "http://127.0.0.1:8000",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only want to align this with the default port on G8S.

handler := s.NewRouter()
// Define our custom not found handler. Here we take care about logging,
// metrics and a proper response.
s.router.NotFoundHandler = http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the router initialization happens only once during boot, which makes perfect sense.

w.Header().Set("Content-Type", "application/json; charset=utf-8")
json.NewEncoder(w).Encode(map[string]interface{}{
"error": errMessage,
"code": responseError.Code(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want to enable microservices to provide a proper response including machine readable codes. This standard applies then across all of our services.

Copy link
Contributor

@JosephSalisbury JosephSalisbury left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🇫🇰

@xh3b4sd xh3b4sd merged commit 3f4cfe8 into master Jan 19, 2017
@xh3b4sd xh3b4sd deleted the error branch January 19, 2017 09:49
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

Successfully merging this pull request may close these issues.

2 participants