(w http.ResponseWriter, r *http.Request)
| 318 | } |
| 319 | |
| 320 | func (mod *RestAPI) sessionRoute(w http.ResponseWriter, r *http.Request) { |
| 321 | mod.setSecurityHeaders(w) |
| 322 | |
| 323 | if !mod.checkAuth(r) { |
| 324 | mod.setAuthFailed(w, r) |
| 325 | return |
| 326 | } else if r.Method == "POST" { |
| 327 | mod.runSessionCommand(w, r) |
| 328 | return |
| 329 | } else if r.Method != "GET" { |
| 330 | http.Error(w, "Bad Request", 400) |
| 331 | return |
| 332 | } |
| 333 | |
| 334 | mod.Session.Lock() |
| 335 | defer mod.Session.Unlock() |
| 336 | |
| 337 | path := r.URL.Path |
| 338 | switch { |
| 339 | case path == "/api/session": |
| 340 | mod.showSession(w, r) |
| 341 | |
| 342 | case path == "/api/session/env": |
| 343 | mod.showEnv(w, r) |
| 344 | |
| 345 | case path == "/api/session/gateway": |
| 346 | mod.showGateway(w, r) |
| 347 | |
| 348 | case path == "/api/session/interface": |
| 349 | mod.showInterface(w, r) |
| 350 | |
| 351 | case strings.HasPrefix(path, "/api/session/modules"): |
| 352 | mod.showModules(w, r) |
| 353 | |
| 354 | case strings.HasPrefix(path, "/api/session/lan"): |
| 355 | mod.showLAN(w, r) |
| 356 | |
| 357 | case path == "/api/session/options": |
| 358 | mod.showOptions(w, r) |
| 359 | |
| 360 | case path == "/api/session/packets": |
| 361 | mod.showPackets(w, r) |
| 362 | |
| 363 | case path == "/api/session/started-at": |
| 364 | mod.showStartedAt(w, r) |
| 365 | |
| 366 | case strings.HasPrefix(path, "/api/session/ble"): |
| 367 | mod.showBLE(w, r) |
| 368 | |
| 369 | case strings.HasPrefix(path, "/api/session/hid"): |
| 370 | mod.showHID(w, r) |
| 371 | |
| 372 | case strings.HasPrefix(path, "/api/session/wifi"): |
| 373 | mod.showWiFi(w, r) |
| 374 | |
| 375 | default: |
| 376 | http.Error(w, "Not Found", 404) |
| 377 | } |
nothing calls this directly
no test coverage detected