-
Notifications
You must be signed in to change notification settings - Fork 8
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
Conversation
@@ -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() |
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.
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", |
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 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) { |
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.
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(), |
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 want to enable microservices to provide a proper response including machine readable codes. This standard applies then across all of our services.
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.
🇫🇰
No description provided.