Drew Short
6 years ago
8 changed files with 49 additions and 43 deletions
-
7rsddns-example.yml
-
14src/config/default.rs
-
1src/config/mod.rs
-
21src/config/model.rs
-
6src/config/validate.rs
-
19src/main.rs
-
0src/server/middleware.rs
-
22src/server/router.rs
@ -0,0 +1,6 @@ |
|||||
|
use crate::config::model::Config;
|
||||
|
use crate::config::error::ConfigError;
|
||||
|
|
||||
|
pub fn validate(config: &Config) -> Result<&Config, ConfigError> {
|
||||
|
Ok(config)
|
||||
|
}
|
@ -1,16 +1,22 @@ |
|||||
extern crate actix_web;
|
extern crate actix_web;
|
||||
|
|
||||
|
use std::sync::Arc;
|
||||
|
|
||||
use actix_web::{App, http};
|
use actix_web::{App, http};
|
||||
use actix_web::middleware::Logger;
|
use actix_web::middleware::Logger;
|
||||
|
|
||||
|
use crate::config::model::Config;
|
||||
use crate::server;
|
use crate::server;
|
||||
|
|
||||
pub fn create() -> App {
|
|
||||
actix_web::App::new()
|
|
||||
.middleware(Logger::default())
|
|
||||
.scope("api/", server::api::route)
|
|
||||
.resource("/health", |r| {
|
|
||||
r.method(http::Method::GET).with(server::healthcheck)
|
|
||||
})
|
|
||||
.resource("/", |r| r.f(server::index))
|
|
||||
|
pub fn factory(config: Arc<Config>) -> impl Fn() -> App + Send + Clone {
|
||||
|
|| {
|
||||
|
actix_web::App::new()
|
||||
|
.middleware(Logger::default())
|
||||
|
.scope("api/", server::api::route)
|
||||
|
// .middleware()
|
||||
|
.resource("/health", |r| {
|
||||
|
r.method(http::Method::GET).with(server::healthcheck)
|
||||
|
})
|
||||
|
.resource("/", |r| r.f(server::index))
|
||||
|
}
|
||||
}
|
}
|
Write
Preview
Loading…
Cancel
Save
Reference in new issue