MCPcopy Create free account
hub / github.com/MG-RAST/Shock / mapRoutes

Function mapRoutes

shock-server/main.go:59–226  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57}
58
59func mapRoutes() {
60 goweb.MapBefore(func(ctx context.Context) error {
61 req := ctx.HttpRequest()
62 host, _, _ := net.SplitHostPort(req.RemoteAddr)
63 if host == "::1" {
64 host = "localhost"
65 }
66 suffix := ""
67 if _, ok := req.Header["Authorization"]; ok {
68 suffix += " AUTH"
69 }
70 if l, has := req.Header["Content-Length"]; has {
71 suffix += " Content-Length: " + l[0]
72 }
73 logger.Infof("%s REQ RECEIVED \"%s %s%s\"", host, ctx.MethodString(), req.RequestURI, suffix)
74 return nil
75 })
76
77 goweb.MapAfter(func(ctx context.Context) error {
78 req := ctx.HttpRequest()
79 host, _, _ := net.SplitHostPort(req.RemoteAddr)
80 if host == "::1" {
81 host = "localhost"
82 }
83 suffix := ""
84 if _, ok := req.Header["Authorization"]; ok {
85 suffix += " AUTH"
86 }
87 if l, has := req.Header["Content-Length"]; has {
88 suffix += " Content-Length: " + l[0]
89 }
90 logger.Infof("RESPONDED TO %s \"%s %s%s\"", host, ctx.MethodString(), req.RequestURI, suffix)
91 return nil
92 })
93
94 goweb.Map("/preauth/{id}", func(ctx context.Context) error {
95 if ctx.HttpRequest().Method == "OPTIONS" {
96 return responder.RespondOK(ctx)
97 }
98 pcon.PreAuthRequest(ctx)
99 return nil
100 })
101
102 goweb.Map("/node/{nid}/acl/{type}", func(ctx context.Context) error {
103 if ctx.HttpRequest().Method == "OPTIONS" {
104 return responder.RespondOK(ctx)
105 }
106 acon.AclTypedRequest(ctx)
107 return nil
108 })
109
110 goweb.Map("/node/{nid}/acl/", func(ctx context.Context) error {
111 if ctx.HttpRequest().Method == "OPTIONS" {
112 return responder.RespondOK(ctx)
113 }
114 acon.AclRequest(ctx)
115 return nil
116 })

Callers 1

mainFunction · 0.85

Calls 7

traceFileNameFunction · 0.85
startTraceFunction · 0.85
stopTraceFunction · 0.85
GetLockedMethod · 0.80
FormatMethod · 0.65
GetAllMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected