Guides  ›  Routes  ›  Methods ← PREV NEXT →

Methods

Put all methods for a path on one route.

module.exports = {
  paths: '/message',
  methods: ['GET', 'POST'],
  handler: function (state) {
    if (state.req.method === 'POST') {
      return { ok: true }
    }
    return 'Send a POST to leave a message'
  }
}

The default is GET. GET also accepts HEAD; HEAD sends headers without a response body. Only POST bodies are parsed.

Next: Auto routes →

Tools for business systems.