keclc-httpauth 0.1.0

HttpAuth support for Kayrx web.
use kayrx::web::dev::ServiceRequest;
use kayrx::web::{middleware, web, App, Error, HttpServer};

use keclc_httpauth::extractors::basic::BasicAuth;
use keclc_httpauth::middleware::HttpAuthentication;

async fn validator(
    req: ServiceRequest,
    _credentials: BasicAuth,
) -> Result<ServiceRequest, Error> {
    Ok(req)
}

#[kayrx::main]
async fn main() -> std::io::Result<()> {
    HttpServer::new(|| {
        let auth = HttpAuthentication::basic(validator);
        App::new()
            .wrap(middleware::Logger::default())
            .wrap(auth)
            .service(web::resource("/").to(|| async { "Test\r\n" }))
    })
    .bind("127.0.0.1:8080")?
    .workers(1)
    .run()
    .await
}