forked from spray/spray
-
Notifications
You must be signed in to change notification settings - Fork 0
Method Filters
Mathias edited this page Nov 17, 2011
·
5 revisions
The most basic directives are the method filters. There is one such directive per HTTP method, so in total there are 7
(delete, get, head, options, post, put, trace). They only let requests with the respective HTTP method
pass to their inner route and reject all others. Method filter directives do not take parameters and do not extract
any values.
Additionally there is also the method directive, which takes an HttpMethod constant as parameter:
import cc.spray.http.HttpMethods._
method(POST) {
...
}If the incoming request has an HTTP method that is different from the one being selected a MethodRejection is being
created, which, by default, triggers a 405 Method not allowed error response if no subsequent route successfully
handles the request.
Filter GET requests:
get {
... // only GET request will get here
}Filter PUT or POST requests:
(put | post) {
... // only PUT and POST requests will get here
}- Home
- Requirements
- spray-server
- ... Getting Started
- ... Key Concepts
- ...... Request Lifecycle
- ...... Routes
- ...... Directives
- ...... Composing Directives
- ...... Rejections
- ...... Marshalling and Unmarshalling
- ... Predefined Directives
- ...... Method Filters
- ...... Path Filters
- ...... Parameter Filters
- ...... Form-Field Filters
- ...... Marshalling/Unmarshalling
- ...... Caching
- ...... Detach
- ...... Encoding/Decoding
- ...... Authentication/Authorization
- ...... File and Resource Directives
- ...... Misc Directives
- ... Advanced Topics
- ...... Case Class Extraction
- ...... Custom Directives
- ...... Custom Media Types
- ...... Custom Error Responses
- ... Configuration
- ... Testing
- ... Example Projects
- spray-client
- Patch Policy
- Credits
- Sponsors