diff options
Diffstat (limited to 'src/routes')
| -rw-r--r-- | src/routes/callback.rs | 2 | ||||
| -rw-r--r-- | src/routes/mod.rs | 12 | ||||
| -rw-r--r-- | src/routes/not_understood.rs | 5 |
3 files changed, 11 insertions, 8 deletions
diff --git a/src/routes/callback.rs b/src/routes/callback.rs index e81a080..4a258ae 100644 --- a/src/routes/callback.rs +++ b/src/routes/callback.rs @@ -11,7 +11,7 @@ pub fn callback(req: HttpRequest, query: Query<HashMap<String, String>>) -> Json content: query.into_inner(), }; - Ok(Json(callback.as_outgoing())) + Ok(FormatMsg::ok(callback.as_outgoing())) } #[cfg(test)] diff --git a/src/routes/mod.rs b/src/routes/mod.rs index 920b172..a631978 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1,4 +1,5 @@ -use actix_web::{web::{route, scope, Json, Query}, HttpRequest, Result, Scope}; +use actix_web::{web::{route, scope, Query}, HttpRequest, Result, Scope}; +use actix_web::http::StatusCode; use messages::*; use std::collections::HashMap; @@ -8,7 +9,7 @@ mod not_understood; use self::callback::callback; use self::not_understood::not_understood; -type JsonMessage<U> = Result<Json<OutgoingMsg<U>>>; +type JsonMessage<U> = Result<FormatMsg<OutgoingMsg<U>>>; // Provides the routes for the application pub fn get_scope() -> Scope { @@ -29,7 +30,7 @@ fn destruct_path(path: &str) -> Vec<String> { #[cfg(test)] mod tests { use super::*; - use actix_web::{http::{Method, StatusCode}, test::TestRequest}; + use actix_web::{http::Method, test::TestRequest}; use actix_web::{App, dev::Service, test::{block_on, init_service}}; #[test] @@ -45,7 +46,7 @@ mod tests { // Assert assert_eq!(resp.status(), StatusCode::OK); //TODO assert response is messages::Callback - //assert_eq!(resp.response().json()); + //assert_eq!(Json::from_request(req, resp.payload()).content_type, "CALLBACK"); } #[test] @@ -59,8 +60,7 @@ mod tests { let resp = block_on(srv.call(req)).unwrap(); // Assert - //FIXME NotUnderstood response's code should be NOT_FOUND? - assert_eq!(resp.status(), StatusCode::OK); + assert_eq!(resp.status(), StatusCode::NOT_FOUND); //TODO assert response is messages::NotUnderstood //assert_eq!(resp.response().json()); } diff --git a/src/routes/not_understood.rs b/src/routes/not_understood.rs index c94e6e2..4e30361 100644 --- a/src/routes/not_understood.rs +++ b/src/routes/not_understood.rs @@ -6,7 +6,10 @@ pub fn not_understood(req: HttpRequest) -> JsonMessage<NotUnderstood> { path: destruct_path(req.path()), }; - Ok(Json(message.as_outgoing())) + Ok(FormatMsg { + message: message.as_outgoing(), + code: StatusCode::NOT_FOUND, + }) } #[cfg(test)] |
