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

Function initAllContext

utils_test.go:60–96  ·  view source on GitHub ↗

init request and response context

(param *InitContextParam)

Source from the content-addressed store, hash-verified

58
59// init request and response context
60func 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
98type httpWriter http.Header
99

Callers

nothing calls this directly

Calls 3

NewFunction · 0.85
formatFunction · 0.85
NewResponseFunction · 0.85

Tested by

no test coverage detected