()
| 57 | } |
| 58 | |
| 59 | func 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 | }) |
no test coverage detected