-
Notifications
You must be signed in to change notification settings - Fork 109
Http Methods
Thiago Bustamante edited this page Jan 20, 2019
·
3 revisions
We have decorators for each HTTP method. Theses decorators are used on service methods already bound to a Path route to specify the endpoint at which requests can be made.
The following decorators can be used:
| Decorator | Description |
|---|---|
| @GET | For HTTP GET operation |
| @POST | For HTTP POST operation |
| @PUT | For HTTP PUT operation |
| @PATCH | For HTTP PATCH operation |
| @DELETE | For HTTP DELETE operation |
| @OPTIONS | For HTTP OPTIONS operation |
| @HEAD | For HTTP HEAD operation |
Some examples:
@Path("/users")
class UserService {
@GET
getUsers(): Promise<Array<User>> {
//...
}
@GET
@Path(":userId")
getUser(@PathParam("userId")): Promise<User> {
//...
}
@PUT
@Path(":userId")
saveUser(@PathParam("userId"), user: User): void {
//...
}
}Only methods decorated with one of this HTTP method decorators are exposed as handlers for requests on the server.
A single method can only be decorated with one of those decorators at a time.
- Server
- @Path Decorator
- Http Methods
- Request Parameters
- Types and languages
- @BodyOptions Decorator
- Service Context
- Service Return
- @Security Decorator
- Express Middlewares
- @PreProcessor Decorator
- @PostProcessor Decorator
- Server Errors
- Service Factory and IoC
- Inheritance and Abstract Services
- Swagger Documentation