Compare commits

...

2 Commits

Author SHA1 Message Date
Adrien Marquès d57f60c710
set content-type to json before writing response
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details
2020-03-22 14:05:47 +01:00
Adrien Marquès ad6de97979
fix: actually get service handler 2020-03-22 14:05:32 +01:00
1 changed files with 2 additions and 0 deletions

View File

@ -60,6 +60,7 @@ func (server httpServer) ServeHTTP(res http.ResponseWriter, req *http.Request) {
for _, handler := range server.handlers { for _, handler := range server.handlers {
if handler.GetMethod() == service.Method && handler.GetPath() == service.Pattern { if handler.GetMethod() == service.Method && handler.GetPath() == service.Pattern {
foundHandler = handler
found = true found = true
} }
} }
@ -96,6 +97,7 @@ func (server httpServer) ServeHTTP(res http.ResponseWriter, req *http.Request) {
foundHandler.Handle(*apireq, response) foundHandler.Handle(*apireq, response)
// 11. apply headers // 11. apply headers
res.Header().Set("Content-Type", "application/json; charset=utf-8")
for key, values := range response.Headers { for key, values := range response.Headers {
for _, value := range values { for _, value := range values {
res.Header().Add(key, value) res.Header().Add(key, value)