common init context
(param *InitContextParam)
| 13 | |
| 14 | // common init context |
| 15 | func initContext(param *InitContextParam) *HttpContext { |
| 16 | httpRequest := &http.Request{} |
| 17 | context := &HttpContext{ |
| 18 | request: &Request{ |
| 19 | Request: httpRequest, |
| 20 | }, |
| 21 | httpServer: &HttpServer{ |
| 22 | DotApp: New(), |
| 23 | }, |
| 24 | } |
| 25 | header := make(map[string][]string) |
| 26 | header["Accept-Encoding"] = []string{"gzip, deflate"} |
| 27 | header["Accept-Language"] = []string{"en-us"} |
| 28 | header["Foo"] = []string{"Bar", "two"} |
| 29 | // specify json |
| 30 | header["Content-Type"] = []string{param.contentType} |
| 31 | context.request.Header = header |
| 32 | |
| 33 | jsonStr := param.convertHandler(param.t, param.v) |
| 34 | body := format(jsonStr) |
| 35 | context.request.Request.Body = body |
| 36 | |
| 37 | return context |
| 38 | } |
| 39 | |
| 40 | // init response context |
| 41 | func initResponseContext(param *InitContextParam) *HttpContext { |
no test coverage detected