MCPcopy Create free account
hub / github.com/cloudwan/gohan / serveResponse

Function serveResponse

extension/gohanscript/lib/httpserver.go:39–52  ·  view source on GitHub ↗
(w http.ResponseWriter, context map[string]interface{})

Source from the content-addressed store, hash-verified

37}
38
39func serveResponse(w http.ResponseWriter, context map[string]interface{}) {
40 response := context["response"]
41 responseCode, ok := context["code"].(int)
42 if !ok {
43 responseCode = 200
44 }
45 if 200 <= responseCode && responseCode < 300 {
46 w.WriteHeader(responseCode)
47 routes.ServeJson(w, response)
48 } else {
49 message := util.MaybeMap(context["exception"])
50 middleware.HTTPJSONError(w, message["message"].(string), responseCode)
51 }
52}
53
54func fillInContext(context middleware.Context,
55 r *http.Request, w http.ResponseWriter, p martini.Params) {

Callers 1

httpServerFunction · 0.85

Calls 1

MaybeMapMethod · 0.80

Tested by

no test coverage detected