mirror of
https://github.com/NetworkCats/rustyip.git
synced 2026-11-13 16:17:46 +00:00
feat: serve openapi.json at /openapi.json endpoint
This commit is contained in:
@@ -329,6 +329,14 @@ pub async fn tor_handler(
|
||||
Ok(format!("{}\n", proxy.is_tor))
|
||||
}
|
||||
|
||||
pub async fn openapi_json() -> Response {
|
||||
(
|
||||
[(header::CONTENT_TYPE, "application/json; charset=utf-8")],
|
||||
include_str!("../openapi.json"),
|
||||
)
|
||||
.into_response()
|
||||
}
|
||||
|
||||
pub async fn robots_txt(State(state): State<AppState>) -> Response {
|
||||
let body = format!(
|
||||
"User-agent: *\n\
|
||||
@@ -344,6 +352,7 @@ pub async fn robots_txt(State(state): State<AppState>) -> Response {
|
||||
Disallow: /hosting\n\
|
||||
Disallow: /tor\n\
|
||||
Disallow: /health\n\
|
||||
Disallow: /openapi.json\n\
|
||||
\n\
|
||||
Sitemap: https://{}/sitemap.xml\n",
|
||||
state.site_domain
|
||||
|
||||
+2
-1
@@ -1,6 +1,6 @@
|
||||
use axum::Router;
|
||||
use axum::middleware;
|
||||
use axum::routing::get;
|
||||
use axum::Router;
|
||||
|
||||
use crate::handlers::{self, AppState};
|
||||
use crate::middleware::security_headers;
|
||||
@@ -10,6 +10,7 @@ pub fn build_router(state: AppState) -> Router {
|
||||
Router::new()
|
||||
.route("/", get(handlers::root))
|
||||
.route("/health", get(handlers::health))
|
||||
.route("/openapi.json", get(handlers::openapi_json))
|
||||
.route("/robots.txt", get(handlers::robots_txt))
|
||||
.route("/sitemap.xml", get(handlers::sitemap_xml))
|
||||
.route("/json", get(handlers::json_handler))
|
||||
|
||||
Reference in New Issue
Block a user