Skip to content

Http Methods

Thiago Bustamante edited this page Jan 20, 2019 · 3 revisions

Http Methods

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:

  • @GET
  • @POST
  • @PUT
  • @PATCH
  • @DELETE
  • @OPTIONS
  • @HEAD

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.

Clone this wiki locally