From 540eec0c826bc01af1b23042290bcfec7aa176f5 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 13 Sep 2019 12:21:36 -0700 Subject: API docs default to redoc, not swagger-ui --- rust/src/bin/fatcatd.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'rust/src') diff --git a/rust/src/bin/fatcatd.rs b/rust/src/bin/fatcatd.rs index 67ec3123..4d1f1a88 100644 --- a/rust/src/bin/fatcatd.rs +++ b/rust/src/bin/fatcatd.rs @@ -107,13 +107,22 @@ fn main() -> Result<()> { let mut router = fatcat_openapi::router(server); router.get("/", root_handler, "root-redirect"); + router.get("/redoc", redoc_handler, "redoc-html"); router.get("/swagger-ui", swaggerui_handler, "swagger-ui-html"); router.get("/v0/openapi2.yml", yaml_handler, "openapi2-spec-yaml"); fn root_handler(_: &mut Request) -> IronResult { Ok(Response::with(( status::Found, - RedirectRaw("/swagger-ui".to_string()), + RedirectRaw("/redoc".to_string()), + ))) + } + fn redoc_handler(_: &mut Request) -> IronResult { + let html_type = "text/html".parse::().unwrap(); + Ok(Response::with(( + html_type, + status::Ok, + include_str!("../../redoc/index.html"), ))) } fn swaggerui_handler(_: &mut Request) -> IronResult { -- cgit v1.2.3