Skip to content

Commit

Permalink
fix(http): Set Content-Type on response
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Seguin committed Aug 11, 2020
1 parent 4baa196 commit d72939d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions httputils.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type APIResponse struct {

// respond response returns a JSON response to the client.
func (s *server) respond(w http.ResponseWriter, r *http.Request, resp interface{}) {
w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
encoder := json.NewEncoder(w)
err := encoder.Encode(resp)
Expand All @@ -27,6 +28,7 @@ func (s *server) respond(w http.ResponseWriter, r *http.Request, resp interface{
func (s *server) error(w http.ResponseWriter, r *http.Request, err error) {
log.Printf("returning error response: %v", err)

w.Header().Add("Content-Type", "application/json")
w.WriteHeader(http.StatusInternalServerError)
encoder := json.NewEncoder(w)
werr := encoder.Encode(APIResponse{
Expand Down
23 changes: 23 additions & 0 deletions test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "test4",
"namespace": "zachary-seguin",
"image": "k8scc01covidacr.azurecr.io/minimal-notebook-cpu:d58600076b0c188364d8651d3986ee0d37ecb4ad",
"customImage": "",
"customImageCheck": false,
"cpu": "0.5",
"memory": "1.0Gi",
"gpus": {
"num": "none"
},
"noWorkspace": false,
"workspace": {
"type": "Existing",
"name": "workspace-test4",
"templatedName": "workspace-{notebook-name}",
"class": "{none}",
"extraFields": {}
},
"datavols": [],
"shm": true,
"configurations": ["minio-profile"]
}

0 comments on commit d72939d

Please sign in to comment.