-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.go
More file actions
60 lines (58 loc) · 1.42 KB
/
Copy pathutils.go
File metadata and controls
60 lines (58 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
//var proxy = goproxy.NewProxyHttpServer()
//func (*App) Fetch(u string, o map[string]interface{}) map[string]interface{} {
// var body io.Reader
// method := http.MethodGet
// header := make(http.Header)
//
// if headers, ex := o["headers"]; ex {
// if hmap, okh := headers.(map[string]interface{}); okh {
// for key, value := range hmap {
// v := value.([]interface{})
// for _, item := range v {
// var i []string
// i = append(i, item.(string))
// header[textproto.CanonicalMIMEHeaderKey(key)] = i
// }
// }
// }
// }
//
// if b, ex := o["body"]; ex {
// if bo, ok := b.(string); ok {
// body = bytes.NewBufferString(bo)
// }
// }
//
// if m, ex := o["method"]; ex {
// if me, ok := m.(string); ok {
// method = me
// }
// }
//
// var toRet map[string]interface{}
//
// res := httptest.NewRecorder()
// req, err := http.NewRequest(method, u, body)
// if err != nil {
// toRet = map[string]interface{}{
// "body": fmt.Sprintf("Internal Server Error: %s", err.Error()),
// "headers": make(map[string][]string),
// "status": http.StatusInternalServerError,
// "method": method,
// "url": u,
// }
// } else {
// req.Header = header
// proxy.ServeHTTP(res, req)
// toRet = map[string]interface{}{
// "body": res.Body.String(),
// "headers": map[string][]string(res.Header()),
// "status": res.Code,
// "method": method,
// "url": u,
// }
// }
//
// return toRet
//}