Comments (5)
Fwiw, I spent a bit of time trying to fix this today, but failed to bend Actix to my will. Essentially I was hoping to use App::default_resource
like so:
diff --git a/src/server/mod.rs b/src/server/mod.rs
index 0530100..fb60c6e 100644
--- a/src/server/mod.rs
+++ b/src/server/mod.rs
@@ -74,7 +74,11 @@ pub fn build_app(state: ServerState) -> App<ServerState> {
.middleware(middleware::WeaveTimestamp)
.middleware(middleware::DbTransaction)
.middleware(middleware::PreConditionCheck)
- .configure(|app| init_routes!(Cors::for_app(app)).register())
+ .configure(|app| {
+ init_routes!(Cors::for_app(app))
+ .register()
+ .default_resource(|r| r.f(handlers::not_found))
+ })
}
pub struct Server {}
diff --git a/src/web/handlers.rs b/src/web/handlers.rs
index 685f831..060579e 100644
--- a/src/web/handlers.rs
+++ b/src/web/handlers.rs
@@ -1,7 +1,7 @@
//! API Handlers
use std::collections::HashMap;
-use actix_web::{http::StatusCode, FutureResponse, HttpResponse, State};
+use actix_web::{http::StatusCode, FutureResponse, HttpRequest, HttpResponse, State};
use futures::future::{self, Either, Future};
use serde::Serialize;
@@ -368,3 +368,9 @@ pub fn get_configuration(
) -> FutureResponse<HttpResponse> {
Box::new(future::result(Ok(HttpResponse::Ok().json(&*state.limits))))
}
+
+pub fn not_found(req: &HttpRequest<ServerState>) -> HttpResponse {
+ req.build_response(StatusCode::NOT_FOUND)
+ .content_type("application/json")
+ .body("0")
+}
Not sure if the cors stuff is affecting it or maybe I've misunderstood the docs/example. Anyway, just recording what I tried, I can come back to this later (want to try and achieve something tangible before today's meeting, lol).
Branch: pb/115
from syncstorage-rs.
@philbooth tried out this branch against the e2e test w/ RUST_LOG=actix_web=debug: which spit out actix_web::pipeline: Error occured during request handling: missing field `uid`
caused by HawkIdentifier::from_request in the PreconditionCheck response.
So errors from middlewares short circuit the request handling.
2019-06-04 edit: RUSTLOG
-> RUST_LOG
from syncstorage-rs.
Looking at latest master:
GET /some/url
=> 404
GET /1.5/some/url
=> 401
Is this still a valid bug? Do we want to do a resource check before authorization (I'd think we'd want to know the request is valid before we do a resource check)?
from syncstorage-rs.
The test still fails (still a valid issue) but it's probably the least important of the failing e2e tests.
Let's hold off on this one for now, as it's dependent on actix-web's middleware behavior which significantly changes in 1.0.
The current middlewares could either be more careful to avoid error responses in cases like this or possibly they could check the request to determine if the route had a specific match (if no match, don't do anything, we're 404ing anyway).
..but let's wait for 1.0 to have a chance to settle
from syncstorage-rs.
This was fixed during the actix-web 1.0 upgrade #126
from syncstorage-rs.
Related Issues (20)
- Add FxA Webhook event handling to Tokenserver
- Feat: Helm chart? HOT 2
- Handle Spanner Migration replaced_at records in the purge_old_records script HOT 1
- Create Product dashboard (in Looker)
- Remove browserid from tokenserver and syncserver documentation HOT 2
- Catalog all Syncstorage and Tokenserver metrics HOT 1
- Update README file
- `secret` is missing from this call HOT 1
- Add ReportableError hooks for adding tags/extras to metrics/sentry events HOT 1
- Syncserver not working with error .../1.5/1/info/collections failed with status 401 in sync-log
- Is there a way to restrict usage
- Is it possible to run thos without the google cloud? HOT 3
- tools/tokenserver: package or not? HOT 4
- Bump python libs per security alerts HOT 2
- Investigate Cloud Spanner's managed TTL feature
- Support alternative system memory allocators (malloc)
- Quiet dbg! calls HOT 1
- Incorrect venv setup causes fxa module to not be found (MySQL) HOT 2
- Complete a technical breakdown for decommissioning Tokenserver
- Improve From<ErrorKind> for Error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from syncstorage-rs.