| 402 | type Response = ServiceResponse; |
| 403 | |
| 404 | fn call(&self, req: Request<Incoming>) -> Self::Future { |
| 405 | let code_tx: CodeSender = std::sync::Arc::clone(&self.code_tx); |
| 406 | let host = self.host.clone(); |
| 407 | Box::pin(async move { |
| 408 | debug!(?req, "Handling connection"); |
| 409 | match req.uri().path() { |
| 410 | "/oauth/callback" | "/oauth/callback/" => Self::handle_oauth_callback(code_tx, host, req).await, |
| 411 | "/index.html" => Ok(Response::builder() |
| 412 | .status(200) |
| 413 | .header("Content-Type", "text/html") |
| 414 | .header("Connection", "close") |
| 415 | .body(include_str!("./index.html").into()) |
| 416 | .expect("valid builder will not panic")), |
| 417 | _ => Ok(Response::builder() |
| 418 | .status(404) |
| 419 | .body("".into()) |
| 420 | .expect("valid builder will not panic")), |
| 421 | } |
| 422 | }) |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | /// Query params for the initial GET request that starts the PKCE flow. Use |