2019-03-31 20:14:56 +02:00
|
|
|
use actix_web::{HttpRequest, HttpResponse};
|
2019-04-25 00:37:29 +02:00
|
|
|
use askama::Template;
|
|
|
|
use utils::AppState;
|
2019-03-24 21:17:55 +01:00
|
|
|
|
2019-03-31 20:14:56 +02:00
|
|
|
#[derive(Template)]
|
|
|
|
#[template(path = "index.html")]
|
|
|
|
struct IndexView;
|
|
|
|
|
2019-04-25 00:37:29 +02:00
|
|
|
pub fn index(_req: HttpRequest<AppState>) -> HttpResponse {
|
|
|
|
HttpResponse::Ok()
|
|
|
|
.content_type("text/html")
|
|
|
|
.body(IndexView.render().unwrap())
|
2019-03-30 23:49:47 +01:00
|
|
|
}
|
|
|
|
|
2019-04-25 00:37:29 +02:00
|
|
|
pub fn hub(_req: HttpRequest<AppState>) -> HttpResponse {
|
2019-03-31 20:14:56 +02:00
|
|
|
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};
|
2019-04-25 00:37:29 +02:00
|
|
|
use utils::setup_logging;
|
2019-03-26 00:10:36 +01:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_index() {
|
2019-04-25 00:37:29 +02:00
|
|
|
let resp = index(
|
|
|
|
test::TestRequest::with_state(AppState {
|
|
|
|
log: setup_logging(),
|
|
|
|
})
|
|
|
|
.finish(),
|
|
|
|
);
|
2019-03-31 20:14:56 +02:00
|
|
|
assert_eq!(resp.status(), http::StatusCode::OK);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_hub() {
|
2019-04-25 00:37:29 +02:00
|
|
|
let resp = hub(test::TestRequest::with_state(AppState {
|
|
|
|
log: setup_logging(),
|
|
|
|
})
|
|
|
|
.finish());
|
2019-03-26 00:10:36 +01:00
|
|
|
assert_eq!(resp.status(), http::StatusCode::OK);
|
|
|
|
}
|
|
|
|
}
|