health route
This commit is contained in:
parent
a406f059e3
commit
89e2772ce6
|
@ -1,7 +1,7 @@
|
|||
#[macro_use]
|
||||
extern crate diesel;
|
||||
|
||||
use actix_web::{dev::ServiceRequest, web, App, Error, HttpServer};
|
||||
use actix_web::{dev::ServiceRequest, web, App, Error, HttpServer, HttpResponse};
|
||||
use actix_web_httpauth::{
|
||||
extractors::{
|
||||
bearer::{BearerAuth, Config},
|
||||
|
@ -36,6 +36,9 @@ async fn main() -> std::io::Result<()> {
|
|||
HttpServer::new(move || {
|
||||
let auth = HttpAuthentication::bearer(validator);
|
||||
App::new()
|
||||
.service(web::resource("/health").to(|| {
|
||||
HttpResponse::Ok().finish()
|
||||
}))
|
||||
.wrap(auth)
|
||||
.data(pool.clone())
|
||||
.route("/users", web::get().to(handlers::get_users))
|
||||
|
@ -53,6 +56,7 @@ async fn validator(req: ServiceRequest, credentials: BearerAuth) -> Result<Servi
|
|||
.app_data::<Config>()
|
||||
.map(|data| data.get_ref().clone())
|
||||
.unwrap_or_else(Default::default);
|
||||
|
||||
match auth::validate_token(credentials.token()).await {
|
||||
Ok(res) => {
|
||||
if res == true {
|
||||
|
|
Loading…
Reference in New Issue