2019-03-31 20:14:56 +02:00
|
|
|
use actix_web::{HttpRequest, HttpResponse};
|
|
|
|
use askama::{Template};
|
2019-03-24 21:17:55 +01:00
|
|
|
|
2019-03-31 20:14:56 +02:00
|
|
|
#[derive(Template)]
|
|
|
|
#[template(path = "index.html")]
|
|
|
|
struct IndexView;
|
|
|
|
|
|
|
|
|
|
|
|
pub fn index(_req: HttpRequest) -> HttpResponse {
|
|
|
|
HttpResponse::Ok().content_type("text/html").body(
|
|
|
|
IndexView.render().unwrap()
|
|
|
|
)
|
2019-03-30 23:49:47 +01:00
|
|
|
}
|
|
|
|
|
2019-03-31 20:14:56 +02:00
|
|
|
pub fn hub(_req: HttpRequest) -> HttpResponse {
|
|
|
|
HttpResponse::Ok().body("Hello World!")
|
2019-03-24 21:17:55 +01:00
|
|
|
}
|
2019-03-26 00:10:36 +01:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
|
|
|
use actix_web::{http, test};
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_index() {
|
2019-03-31 20:14:56 +02:00
|
|
|
let resp = index(test::TestRequest::default().finish());
|
|
|
|
assert_eq!(resp.status(), http::StatusCode::OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_hub() {
|
|
|
|
let resp = hub(test::TestRequest::default().finish());
|
2019-03-26 00:10:36 +01:00
|
|
|
assert_eq!(resp.status(), http::StatusCode::OK);
|
|
|
|
}
|
|
|
|
}
|