add initial validation structure
This commit is contained in:
parent
ed18c442f2
commit
6811ba8715
|
@ -192,7 +192,7 @@ dependencies = [
|
||||||
"humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"humansize 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
"num-traits 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)",
|
"serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
"toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -1204,6 +1204,7 @@ dependencies = [
|
||||||
"slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"slog-async 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"slog-term 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"slog-term 2.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
"toml 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
"toml 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
"url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -1246,7 +1247,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.89"
|
version = "1.0.90"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
"proc-macro2 0.4.27 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
|
@ -2032,7 +2033,7 @@ dependencies = [
|
||||||
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
|
||||||
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
|
||||||
"checksum serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "92514fb95f900c9b5126e32d020f5c6d40564c27a5ea6d1d7d9f157a96623560"
|
"checksum serde 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "92514fb95f900c9b5126e32d020f5c6d40564c27a5ea6d1d7d9f157a96623560"
|
||||||
"checksum serde_derive 1.0.89 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6eabf4b5914e88e24eea240bb7c9f9a2cbc1bbbe8d961d381975ec3c6b806c"
|
"checksum serde_derive 1.0.90 (registry+https://github.com/rust-lang/crates.io-index)" = "58fc82bec244f168b23d1963b45c8bf5726e9a15a9d146a067f9081aeed2de79"
|
||||||
"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d"
|
"checksum serde_json 1.0.39 (registry+https://github.com/rust-lang/crates.io-index)" = "5a23aa71d4a4d43fdbfaac00eff68ba8a06a51759a89ac3304323e800c4dd40d"
|
||||||
"checksum serde_urlencoded 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d48f9f99cd749a2de71d29da5f948de7f2764cc5a9d7f3c97e3514d4ee6eabf2"
|
"checksum serde_urlencoded 0.5.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d48f9f99cd749a2de71d29da5f948de7f2764cc5a9d7f3c97e3514d4ee6eabf2"
|
||||||
"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
|
"checksum sha1 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d"
|
||||||
|
|
|
@ -12,3 +12,4 @@ askama = "0.8"
|
||||||
slog = "2.4.1"
|
slog = "2.4.1"
|
||||||
slog-term = "2.4.0"
|
slog-term = "2.4.0"
|
||||||
slog-async = "2.3.0"
|
slog-async = "2.3.0"
|
||||||
|
url = "1.7.2"
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
pub fn create_subscription() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub fn remove_subscription() {
|
||||||
|
|
||||||
|
}
|
|
@ -1,6 +1,8 @@
|
||||||
use actix_web::{HttpRequest, HttpResponse};
|
use actions::{create_subscription, remove_subscription};
|
||||||
|
use actix_web::{http, HttpRequest, HttpResponse};
|
||||||
use askama::Template;
|
use askama::Template;
|
||||||
use utils::AppState;
|
use url::form_urlencoded;
|
||||||
|
use utils::{validate_parsed_data, AppState};
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "index.html")]
|
#[template(path = "index.html")]
|
||||||
|
@ -12,7 +14,18 @@ pub fn index(_req: HttpRequest<AppState>) -> HttpResponse {
|
||||||
.body(IndexView.render().unwrap())
|
.body(IndexView.render().unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn hub(_req: HttpRequest<AppState>) -> HttpResponse {
|
pub fn hub(_req: HttpRequest<AppState>, params: String) -> HttpResponse {
|
||||||
|
let log = &_req.state().log;
|
||||||
|
info!(log, "Received Request");
|
||||||
|
debug!(log, "Content: {}", params);
|
||||||
|
let parsed_data = form_urlencoded::parse(params.as_bytes());
|
||||||
|
|
||||||
|
if !validate_parsed_data(parsed_data) {
|
||||||
|
return HttpResponse::Ok()
|
||||||
|
.status(http::StatusCode::from_u16(400).unwrap())
|
||||||
|
.finish();
|
||||||
|
}
|
||||||
|
|
||||||
HttpResponse::Ok().body("Hello World!")
|
HttpResponse::Ok().body("Hello World!")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ extern crate diesel;
|
||||||
extern crate slog;
|
extern crate slog;
|
||||||
extern crate slog_async;
|
extern crate slog_async;
|
||||||
extern crate slog_term;
|
extern crate slog_term;
|
||||||
|
extern crate url;
|
||||||
use actix_web::actix::{SyncArbiter, System};
|
use actix_web::actix::{SyncArbiter, System};
|
||||||
use actix_web::{http, server, App};
|
use actix_web::{http, server, App};
|
||||||
use clap::Arg;
|
use clap::Arg;
|
||||||
|
@ -14,6 +15,7 @@ use controllers::{hub, index};
|
||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
use utils::{setup_logging, AppState, DbExecutor};
|
use utils::{setup_logging, AppState, DbExecutor};
|
||||||
|
|
||||||
|
mod actions;
|
||||||
mod controllers;
|
mod controllers;
|
||||||
mod models;
|
mod models;
|
||||||
mod schema;
|
mod schema;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use actix_web::actix::{Actor, Addr, SyncContext};
|
use actix_web::actix::{Actor, Addr, SyncContext};
|
||||||
use diesel::prelude::*;
|
use diesel::prelude::*;
|
||||||
use slog::Drain;
|
use slog::Drain;
|
||||||
|
use url::form_urlencoded::Parse;
|
||||||
|
|
||||||
pub struct DbExecutor(pub SqliteConnection);
|
pub struct DbExecutor(pub SqliteConnection);
|
||||||
|
|
||||||
|
@ -19,3 +20,7 @@ pub fn setup_logging() -> slog::Logger {
|
||||||
let drain = slog_async::Async::new(drain).build().fuse();
|
let drain = slog_async::Async::new(drain).build().fuse();
|
||||||
slog::Logger::root(drain, o!())
|
slog::Logger::root(drain, o!())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn validate_parsed_data(data: Parse) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue