diff --git a/api/response.go b/api/response.go index 2b2d96e..a6ea101 100644 --- a/api/response.go +++ b/api/response.go @@ -11,6 +11,7 @@ type ResponseData map[string]interface{} // Response represents an API response to be sent type Response struct { Data ResponseData + Status int Headers http.Header Err Error } @@ -18,8 +19,10 @@ type Response struct { // NewResponse creates an empty response func NewResponse() *Response { return &Response{ - Data: make(ResponseData), - Err: ErrorFailure(), + Status: http.StatusOK, + Data: make(ResponseData), + Err: ErrorFailure(), + Headers: make(http.Header), } } diff --git a/util.go b/util.go index e371623..305304d 100644 --- a/util.go +++ b/util.go @@ -87,6 +87,7 @@ func (s *Server) extractParameters(store *reqdata.Store, methodParam map[string] // Prints an HTTP response func httpPrint(r http.ResponseWriter, res *api.Response) { + r.WriteHeader(res.Status) // write this json jsonResponse, _ := json.Marshal(res)