From baa8595a4a14dff11904e7b727f92f90c6aad051 Mon Sep 17 00:00:00 2001 From: landrigun Date: Fri, 14 Oct 2022 10:45:32 +0000 Subject: [PATCH] fix doc + set route target in const --- src/http/router.rs | 8 ++++++-- src/main.rs | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/http/router.rs b/src/http/router.rs index b1bd817..48c74d8 100644 --- a/src/http/router.rs +++ b/src/http/router.rs @@ -7,6 +7,10 @@ use crate::jwt::JWTSigner; use crate::stores::FileStore; use crate::stores::Store; +// TODO: must be mapped with corresponding handler +const GET_ROUTE: &'static str = "/get/"; +const VALIDATE_ROUTE: &'static str = "/validate/"; + async fn handle_get(request: HTTPRequest, config: Config) -> HTTPResponse { let mut store = FileStore::new(config.filestore_path.clone()); match &request.body { @@ -58,8 +62,8 @@ impl Router { let target = request.start_line.get_target(); match target.as_str() { - "/get/" => handle_get(request, config).await, - "/validate/" => handle_validate(request, config).await, + GET_ROUTE => handle_get(request, config).await, + VALIDATE_ROUTE => handle_validate(request, config).await, _ => HTTPResponse::as_404(), } } diff --git a/src/main.rs b/src/main.rs index 04c8f13..7a75f69 100644 --- a/src/main.rs +++ b/src/main.rs @@ -72,7 +72,7 @@ async fn handle_connection(mut stream: TcpStream, config: Config) { let duration = Duration::from_micros(500); // loop until the message is read - // the stream can be fragmented so, using a timout (500um should be enough) for the future for completion + // the stream can be fragmented so, using a timeout (500um should be enough) for the future for completion // after the timeout, the message is "considered" as entirely read loop { match timeout(duration, stream.read(&mut buffer)).await {