From 18d4e86a7ec06ec032ffa338a29156045f8112d5 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 23 May 2018 18:23:11 -0700 Subject: add redirect to swagger UI --- rust/src/bin/fatcatd.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'rust/src/bin') diff --git a/rust/src/bin/fatcatd.rs b/rust/src/bin/fatcatd.rs index 19357c9e..d4bc2683 100644 --- a/rust/src/bin/fatcatd.rs +++ b/rust/src/bin/fatcatd.rs @@ -17,7 +17,8 @@ extern crate slog_async; extern crate slog_term; use clap::{App, Arg}; -use iron::{Chain, Iron, IronResult, Response, Request, status}; +use iron::{Chain, Iron, IronResult, Response, Request, status, Url}; +use iron::modifiers::RedirectRaw; use iron_slog::{DefaultLogFormatter, LoggerMiddleware}; use slog::{Drain, Logger}; //use dotenv::dotenv; @@ -44,9 +45,14 @@ fn main() { let server = fatcat::server().unwrap(); let mut router = fatcat_api::router(server); + router.get("/", root_handler, "root-redirect"); 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, Redirect(Url::parse("/swagger-ui").unwrap())))) + Ok(Response::with((status::Found, RedirectRaw("/swagger-ui".to_string())))) + } fn swaggerui_handler(_: &mut Request) -> IronResult { let html_type = "text/html".parse::().unwrap(); Ok(Response::with((html_type, status::Ok, include_str!("../../swagger-ui/index.html")))) -- cgit v1.2.3