diff options
Diffstat (limited to 'rust/src/bin')
-rw-r--r-- | rust/src/bin/fatcatd.rs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/rust/src/bin/fatcatd.rs b/rust/src/bin/fatcatd.rs index f33c3763..19357c9e 100644 --- a/rust/src/bin/fatcatd.rs +++ b/rust/src/bin/fatcatd.rs @@ -17,7 +17,7 @@ extern crate slog_async; extern crate slog_term; use clap::{App, Arg}; -use iron::{Chain, Iron}; +use iron::{Chain, Iron, IronResult, Response, Request, status}; use iron_slog::{DefaultLogFormatter, LoggerMiddleware}; use slog::{Drain, Logger}; //use dotenv::dotenv; @@ -42,7 +42,18 @@ fn main() { let formatter = DefaultLogFormatter; let server = fatcat::server().unwrap(); - let router = fatcat_api::router(server); + let mut router = fatcat_api::router(server); + + router.get("/swagger-ui", swaggerui_handler, "swagger-ui-html"); + router.get("/v0/openapi2.yml", yaml_handler, "openapi2-spec-yaml"); + + fn swaggerui_handler(_: &mut Request) -> IronResult<Response> { + let html_type = "text/html".parse::<iron::mime::Mime>().unwrap(); + Ok(Response::with((html_type, status::Ok, include_str!("../../swagger-ui/index.html")))) + } + fn yaml_handler(_: &mut Request) -> IronResult<Response> { + Ok(Response::with((status::Ok, include_str!("../../fatcat-openapi2.yml")))) + } let mut chain = Chain::new(LoggerMiddleware::new(router, logger, formatter)); |