serveLoginAPI serves requests for the web login client. It should only be called by Server.ServeHTTP, via Server.apiHandler, which protects the handler using gorilla csrf.
(w http.ResponseWriter, r *http.Request)
| 517 | // It should only be called by Server.ServeHTTP, via Server.apiHandler, |
| 518 | // which protects the handler using gorilla csrf. |
| 519 | func (s *Server) serveLoginAPI(w http.ResponseWriter, r *http.Request) { |
| 520 | switch { |
| 521 | case r.URL.Path == "/api/data" && r.Method == httpm.GET: |
| 522 | s.serveGetNodeData(w, r) |
| 523 | case r.URL.Path == "/api/up" && r.Method == httpm.POST: |
| 524 | s.serveTailscaleUp(w, r) |
| 525 | case r.URL.Path == "/api/device-details-click" && r.Method == httpm.POST: |
| 526 | s.serveDeviceDetailsClick(w, r) |
| 527 | default: |
| 528 | http.Error(w, "invalid endpoint or method", http.StatusNotFound) |
| 529 | } |
| 530 | } |
| 531 | |
| 532 | // handleJSON manages decoding the request's body JSON as data and passing it |
| 533 | // on to the provided handler function. |
nothing calls this directly
no test coverage detected