diff options
author | Bryan Newbold <bnewbold@robocracy.org> | 2019-09-13 12:21:36 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@robocracy.org> | 2019-09-13 12:21:36 -0700 |
commit | 540eec0c826bc01af1b23042290bcfec7aa176f5 (patch) | |
tree | 685c08f4fb426ed3ef1283a01e098ff6ed8100fa | |
parent | 0e1ddd94f7f210391dfc34ddcc370d63ef497c16 (diff) | |
download | fatcat-540eec0c826bc01af1b23042290bcfec7aa176f5.tar.gz fatcat-540eec0c826bc01af1b23042290bcfec7aa176f5.zip |
API docs default to redoc, not swagger-ui
-rw-r--r-- | rust/redoc/index.html | 24 | ||||
-rw-r--r-- | rust/src/bin/fatcatd.rs | 11 |
2 files changed, 34 insertions, 1 deletions
diff --git a/rust/redoc/index.html b/rust/redoc/index.html new file mode 100644 index 00000000..ac75c306 --- /dev/null +++ b/rust/redoc/index.html @@ -0,0 +1,24 @@ +<!DOCTYPE html> +<html> + <head> + <title>ReDoc</title> + <!-- needed for adaptive design --> + <meta charset="utf-8"/> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <link href="https://fonts.googleapis.com/css?family=Montserrat:300,400,700|Roboto:300,400,700" rel="stylesheet"> + + <!-- + ReDoc doesn't change outer page styles + --> + <style> + body { + margin: 0; + padding: 0; + } + </style> + </head> + <body> + <redoc spec-url='/v0/openapi2.yml'></redoc> + <script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script> + </body> +</html> 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<Response> { Ok(Response::with(( status::Found, - RedirectRaw("/swagger-ui".to_string()), + RedirectRaw("/redoc".to_string()), + ))) + } + fn redoc_handler(_: &mut Request) -> IronResult<Response> { + let html_type = "text/html".parse::<iron::mime::Mime>().unwrap(); + Ok(Response::with(( + html_type, + status::Ok, + include_str!("../../redoc/index.html"), ))) } fn swaggerui_handler(_: &mut Request) -> IronResult<Response> { |