aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/bin
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-05-23 18:23:11 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-05-24 15:21:32 -0700
commit18d4e86a7ec06ec032ffa338a29156045f8112d5 (patch)
treecc3780447c53bb4a51ff871775ad12a2a792ed40 /rust/src/bin
parenteb8bedb469f837c8943bd07b008117850ef60e48 (diff)
downloadfatcat-18d4e86a7ec06ec032ffa338a29156045f8112d5.tar.gz
fatcat-18d4e86a7ec06ec032ffa338a29156045f8112d5.zip
add redirect to swagger UI
Diffstat (limited to 'rust/src/bin')
-rw-r--r--rust/src/bin/fatcatd.rs8
1 files changed, 7 insertions, 1 deletions
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<Response> {
+ //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<Response> {
let html_type = "text/html".parse::<iron::mime::Mime>().unwrap();
Ok(Response::with((html_type, status::Ok, include_str!("../../swagger-ui/index.html"))))