% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/routing.R
\name{routing-http-methods}
\alias{routing-http-methods}
\title{Routing HTTP Methods}
\arguments{
\item{path}{String. Route to listen to; use \code{:} to define a parameter (e.g.
\code{"/hello/:name"}).}

\item{handler}{Function that accepts the request and response objects and
returns an httpuv response (e.g. \code{\link[=response]{response()}}). Handlers can return the result
of helper functions such as \code{Response$text()}, \code{Response$json()}, or the
output of any renderer.}

\item{error}{Optional handler invoked if the route raises an error; receives
the request, response, and the error condition.}
}
\value{
The routing object invisibly so calls can be chained.
}
\description{
Register route handlers for HTTP verbs on a \code{\link{Routing}} instance.
}
\details{
The routing helpers provide a fluent API for attaching handlers to HTTP
methods. Each helper shares the same signature and behaviour.
\subsection{Supported helpers}{
\itemize{
\item \code{get()}: Respond to HTTP \code{GET} requests.
\item \code{post()}: Respond to HTTP \code{POST} requests.
\item \code{put()}: Respond to HTTP \code{PUT} requests.
\item \code{patch()}: Respond to HTTP \code{PATCH} requests.
\item \code{delete()}: Respond to HTTP \code{DELETE} requests.
\item \code{options()}: Respond to HTTP \code{OPTIONS} requests.
\item \code{all()}: Respond to every method above.
}
}
}
\examples{
app <- Ambiorix$new()

app$get("/", function(req, res) {
  res$text("Hello, world!")
})

app$post("/echo", function(req, res) {
  res$json(list(received = req$body))
})

app$all("/health", function(req, res) {
  res$json(list(status = "ok"))
})

}
\seealso{
\code{\link{Routing}}
}
