Skip to main content

Distinguishing Request Types

In browser developer tools, the request Headers panel identifies the HTTP method:

Header fieldExample
Request URLhttp://www.hasor.net/account/login.htm
Request MethodGET
Status Code200

The Request Method field is the request type used by the annotations below.

If one method should receive every request type, annotate it with @Any. To distinguish request types, use different methods for POST and GET as shown below:

@MappingTo("/helloAction.do")
public class HelloAction {
@Post
public void doPost() {
...
}
@Get
public void doGet() {
...
}
}

Hasor provides the following request-type annotations by default:

AnnotationMeaning
@AnyAny request type
@GetGET request
@PostPOST request
@PutPUT request
@HeadHEAD request
@OptionsOPTION request
tip

Hasor supports marking a handler with multiple request-type annotations at the same time, such as using both @Get and @Post.