HTTP methods

For most of the web, there are five commonly used HTTP methods, which are as follows:

  • GET
  • POST
  • PATCH
  • PUT
  • DELETE
  • OPTIONS

There are also other methods that are less used and can be passed in the request to a web application. If it is able to handle it, the routing rules will determine who should be handling the request.

Vapor's droplets give us easy-to-use APIs to construct routes for these commonly used HTTP methods. All we need to do is call the droplet instance with its appropriate HTTP method. When a request comes to Vapor on the matching path with the same HTTP method, the handler Response for it will be called with the request object. Here you can see how easy it is to set up a route to under /app to accept different HTTP ...

Get Hands-On Full-Stack Development with Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.