Last active
May 24, 2018 23:07
-
-
Save rippinrobr/12f8d0e4cd1a806f68b8f8f1356d70df to your computer and use it in GitHub Desktop.
The updated resource mapping with the default settings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
App::with_state(State{db: addr.clone()}) | |
// the default_resource call here uses a closure | |
// to return 405 Method Not Allowed error for | |
// all routes | |
.default_resource(|r| { | |
r.route().filter(pred::Not(pred::Get())) | |
.f(|req| HttpResponse::MethodNotAllowed()); | |
}) | |
.resource("/", |r| r.method(http::Method::GET).f(index)) | |
.resource("/conspiracies/{page_id}", |r| r.method(http::Method::GET).a(get_conspiracies_by_id)) | |
.resource("/tags", |r| r.method(http::Method::GET).a(get_tags)) | |
.resource("/conspiracies", |r| r.method(http::Method::GET).a(get_conspiracies)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment