init request and response context
(param *InitContextParam)
| 58 | |
| 59 | // init request and response context |
| 60 | func initAllContext(param *InitContextParam) *HttpContext { |
| 61 | context := &HttpContext{ |
| 62 | response: &Response{}, |
| 63 | request: &Request{ |
| 64 | Request: &http.Request{}, |
| 65 | }, |
| 66 | httpServer: &HttpServer{ |
| 67 | DotApp: New(), |
| 68 | }, |
| 69 | routerNode: &Node{}, |
| 70 | } |
| 71 | |
| 72 | header := make(map[string][]string) |
| 73 | header["Accept-Encoding"] = []string{"gzip, deflate"} |
| 74 | header["Accept-Language"] = []string{"en-us"} |
| 75 | header["Foo"] = []string{"Bar", "two"} |
| 76 | // specify json |
| 77 | header["Content-Type"] = []string{param.contentType} |
| 78 | context.request.Header = header |
| 79 | |
| 80 | u := &url.URL{ |
| 81 | Path: "/index", |
| 82 | } |
| 83 | |
| 84 | context.request.URL = u |
| 85 | context.request.Method = "POST" |
| 86 | |
| 87 | jsonStr := param.convertHandler(param.t, param.v) |
| 88 | body := format(jsonStr) |
| 89 | context.request.Request.Body = body |
| 90 | |
| 91 | w := &httpWriter{} |
| 92 | |
| 93 | context.response = NewResponse(w) |
| 94 | |
| 95 | return context |
| 96 | } |
| 97 | |
| 98 | type httpWriter http.Header |
| 99 |
nothing calls this directly
no test coverage detected