fix doc + set route target in const
This commit is contained in:
parent
7336933642
commit
baa8595a4a
@ -7,6 +7,10 @@ use crate::jwt::JWTSigner;
|
|||||||
use crate::stores::FileStore;
|
use crate::stores::FileStore;
|
||||||
use crate::stores::Store;
|
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 {
|
async fn handle_get(request: HTTPRequest, config: Config) -> HTTPResponse {
|
||||||
let mut store = FileStore::new(config.filestore_path.clone());
|
let mut store = FileStore::new(config.filestore_path.clone());
|
||||||
match &request.body {
|
match &request.body {
|
||||||
@ -58,8 +62,8 @@ impl Router {
|
|||||||
let target = request.start_line.get_target();
|
let target = request.start_line.get_target();
|
||||||
|
|
||||||
match target.as_str() {
|
match target.as_str() {
|
||||||
"/get/" => handle_get(request, config).await,
|
GET_ROUTE => handle_get(request, config).await,
|
||||||
"/validate/" => handle_validate(request, config).await,
|
VALIDATE_ROUTE => handle_validate(request, config).await,
|
||||||
_ => HTTPResponse::as_404(),
|
_ => HTTPResponse::as_404(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -72,7 +72,7 @@ async fn handle_connection(mut stream: TcpStream, config: Config) {
|
|||||||
let duration = Duration::from_micros(500);
|
let duration = Duration::from_micros(500);
|
||||||
|
|
||||||
// loop until the message is read
|
// 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
|
// after the timeout, the message is "considered" as entirely read
|
||||||
loop {
|
loop {
|
||||||
match timeout(duration, stream.read(&mut buffer)).await {
|
match timeout(duration, stream.read(&mut buffer)).await {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user