MCPcopy Create free account
hub / github.com/devfeel/dotweb / initContext

Function initContext

utils_test.go:15–38  ·  view source on GitHub ↗

common init context

(param *InitContextParam)

Source from the content-addressed store, hash-verified

13
14// common init context
15func 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
41func initResponseContext(param *InitContextParam) *HttpContext {

Callers 7

TestBinder_Bind_jsonFunction · 0.85
TestBinder_Bind_xmlFunction · 0.85
TestBinder_Bind_defaultFunction · 0.85

Calls 2

NewFunction · 0.85
formatFunction · 0.85

Tested by

no test coverage detected