+ Clearer logging from the json api
* Renamed db helper function to be (debatably) more clear in its intentions That function and everything in that module is quickly become awful however + Adding some notes for later db-lib development
This commit is contained in:
@@ -63,7 +63,7 @@ async fn route_dispatcher(
|
||||
const GET: &Method = &Method::GET;
|
||||
const POST: &Method = &Method::POST;
|
||||
const DELETE: &Method = &Method::DELETE;
|
||||
println!("{}: {}", meth, path);
|
||||
println!("[INFO] {}: {}", meth, path);
|
||||
match (meth, path) {
|
||||
/* INVITES */
|
||||
(POST, routes::INVITE_CREATE) => invites::create(pool, resp, params).await,
|
||||
@@ -88,7 +88,7 @@ async fn route_dispatcher(
|
||||
/* META ROUTE */
|
||||
(GET, routes::META) => meta::server_meta(resp).await,
|
||||
_ => {
|
||||
println!("\tNOT FOUND: {}: {}", meth, path);
|
||||
println!("[INFO]\tNOT FOUND: {}: {}", meth, path);
|
||||
*resp.status_mut() = StatusCode::NOT_FOUND
|
||||
}
|
||||
}
|
||||
@@ -116,11 +116,10 @@ async fn main_responder(request: Request<Body>) -> Result<Response<Body>, hyper:
|
||||
route_dispatcher(&DB_POOL, &mut response, &method, path, body, params, headers).await;
|
||||
},
|
||||
LoginValid => {
|
||||
println!("LoginValid");
|
||||
auth::login_get_jwt(&DB_POOL, &mut response, params).await;
|
||||
},
|
||||
NoKey | BadKey => {
|
||||
println!("NoKey | BadKey");
|
||||
println!("[DEBUG] NoKey | BadKey");
|
||||
*response.status_mut() = StatusCode::UNAUTHORIZED;
|
||||
},
|
||||
ServerIssue(msg) => {
|
||||
@@ -130,7 +129,7 @@ async fn main_responder(request: Request<Body>) -> Result<Response<Body>, hyper:
|
||||
}
|
||||
}
|
||||
else {
|
||||
println!("\tPARSER: Parameter parsing failed");
|
||||
println!("[INFO] PARSER: Parameter parsing failed");
|
||||
*response.status_mut() = StatusCode::BAD_REQUEST;
|
||||
}
|
||||
Ok(response)
|
||||
@@ -143,7 +142,7 @@ async fn shutdown_signal() {
|
||||
}
|
||||
|
||||
async fn start_server(ecode: u16, port: u16) -> u16 {
|
||||
println!("Servering on localhost:{}", port);
|
||||
println!("[INFO] HTTP listening on localhost:{}", port);
|
||||
let addr = SocketAddr::from(([127,0,0,1], port));
|
||||
let service = make_service_fn(|_conn| async {
|
||||
Ok::<_, Infallible>(service_fn(main_responder))
|
||||
|
||||
@@ -68,7 +68,6 @@ pub async fn send_message(pool: &Pool, response: &mut Response<Body>, body: Body
|
||||
let uid = qs_param!(params, "id", u64).unwrap();
|
||||
let ctype: Option<&str> = match headers.get("Content-Type") {
|
||||
Some(hval) => {
|
||||
println!("{:?}", hval);
|
||||
match hval.to_str() {
|
||||
Ok(s) => Some(s),
|
||||
_ => None
|
||||
|
||||
Reference in New Issue
Block a user