| 150 | } |
| 151 | |
| 152 | func (c *AuthVersionHandler) ServeHTTP( |
| 153 | w http.ResponseWriter, req *http.Request) { |
| 154 | defer func() { |
| 155 | if err := recover(); err != nil { |
| 156 | buf := make([]byte, 2048) |
| 157 | n := runtime.Stack(buf, false) |
| 158 | cbgt.PublishCrashEvent(map[string]interface{}{ |
| 159 | "stackTrace": string(buf[:n]), |
| 160 | "crashError": fmt.Sprintf("%v", err), |
| 161 | }) |
| 162 | } |
| 163 | }() |
| 164 | if err := CheckAPIVersion(w, req); err != nil { |
| 165 | return |
| 166 | } |
| 167 | |
| 168 | path := "" |
| 169 | if c.H != nil { |
| 170 | hwrm, ok := c.H.(*rest.HandlerWithRESTMeta) |
| 171 | if ok && hwrm.RESTMeta != nil { |
| 172 | path = hwrm.RESTMeta.Opts["_path"] |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | c.doAudit(req, path) |
| 177 | |
| 178 | wEx := wrapResponseWriter(w) |
| 179 | |
| 180 | ok, username := checkAPIAuth(c, wEx, req, path) |
| 181 | if !ok { |
| 182 | return |
| 183 | } |
| 184 | |
| 185 | if c.H != nil { |
| 186 | c.H.ServeHTTP(wEx, req) |
| 187 | } |
| 188 | |
| 189 | completeRequest(username, path, req, wEx.Length()) |
| 190 | } |
| 191 | |
| 192 | func (c *AuthVersionHandler) doAudit(req *http.Request, path string) { |
| 193 | if c.adtSvc == nil { |