//! The authorization pages' build, embedded when the crate is compiled //! (`build.rs`), and `/oauth/assets/`, which serves it //! (`spec/OAUTH-PAGES.md`, "Assets"). use axum::{ extract::Path, http::{Method, StatusCode, header}, response::{IntoResponse, Response}, }; include!(concat!(env!("OUT_DIR"), "/web.rs")); /// `GET` or `HEAD /oauth/assets/`: a file of the build, which never /// changes under its name. pub(super) async fn asset(method: Method, Path(name): Path) -> Response { let found = ASSETS .binary_search_by_key(&name.as_str(), |(n, _, _)| n) .ok(); match found { Some(i) if method == Method::GET || method == Method::HEAD => { let (_, content_type, bytes) = ASSETS[i]; ( [ (header::CONTENT_TYPE, content_type), (header::CACHE_CONTROL, "public, max-age=31536000, immutable"), (header::X_CONTENT_TYPE_OPTIONS, "nosniff"), ], bytes, ) .into_response() } _ => StatusCode::NOT_FOUND.into_response(), } }