cleanup and comments

This commit is contained in:
Ilion Beyst 2022-07-04 20:11:29 +02:00
parent 7b88bb0502
commit bbed877554

View file

@ -1,6 +1,7 @@
// TODO: this module is functional, but it needs a good refactor for proper error handling.
use axum::body::{Body, StreamBody}; use axum::body::{Body, StreamBody};
use axum::extract::{BodyStream, FromRequest, Path, Query, RequestParts, TypedHeader}; use axum::extract::{BodyStream, FromRequest, Path, Query, RequestParts, TypedHeader};
use axum::handler::Handler;
use axum::headers::authorization::Basic; use axum::headers::authorization::Basic;
use axum::headers::Authorization; use axum::headers::Authorization;
use axum::response::{IntoResponse, Response}; use axum::response::{IntoResponse, Response};
@ -19,13 +20,13 @@ use crate::{db, DatabaseConnection};
use crate::db::users::{authenticate_user, Credentials, User}; use crate::db::users::{authenticate_user, Credentials, User};
// TODO: put this in a config file
const REGISTRY_PATH: &str = "./data/registry"; const REGISTRY_PATH: &str = "./data/registry";
pub fn registry_service() -> Router { pub fn registry_service() -> Router {
Router::new() Router::new()
// The docker API requires this trailing slash // The docker API requires this trailing slash
.nest("/v2/", registry_api_v2()) .nest("/v2/", registry_api_v2())
.fallback(fallback.into_service())
} }
fn registry_api_v2() -> Router { fn registry_api_v2() -> Router {
@ -46,12 +47,6 @@ fn registry_api_v2() -> Router {
) )
} }
async fn fallback(request: axum::http::Request<Body>) -> impl IntoResponse {
// for debugging
println!("no route for {} {}", request.method(), request.uri());
StatusCode::NOT_FOUND
}
const ADMIN_USERNAME: &str = "admin"; const ADMIN_USERNAME: &str = "admin";
// TODO: put this in some configuration // TODO: put this in some configuration
const ADMIN_PASSWORD: &str = "supersecretpassword"; const ADMIN_PASSWORD: &str = "supersecretpassword";