% Generated by roxygen2: do not edit by hand % Please edit documentation in R/router.R \name{Router} \alias{Router} \title{Router} \value{ A Router object. } \description{ Web server. } \examples{ # log logger <- new_log() # router # create router router <- Router$new("/users") router$get("/", function(req, res){ res$send("List of users") }) router$get("/:id", function(req, res){ logger$log("Return user id:", req$params$id) res$send(req$params$id) }) router$get("/:id/profile", function(req, res){ msg <- sprintf("This is the profile of user #\%s", req$params$id) res$send(msg) }) # core app app <- Ambiorix$new() app$get("/", function(req, res){ res$send("Home!") }) # mount the router app$use(router) if(interactive()) app$start() } \section{Super class}{ \code{\link[ambiorix:Routing]{ambiorix::Routing}} -> \code{Router} } \section{Public fields}{ \if{html}{\out{
}} \describe{ \item{\code{error}}{500 response when the route errors, must a handler function that accepts the request and the response, by default uses \code{\link[=response_500]{response_500()}}.} } \if{html}{\out{
}} } \section{Methods}{ \subsection{Public methods}{ \itemize{ \item \href{#method-Router-new}{\code{Router$new()}} \item \href{#method-Router-print}{\code{Router$print()}} \item \href{#method-Router-clone}{\code{Router$clone()}} } } \if{html}{\out{
Inherited methods

- `ambiorix::Routing$engine()`
- `ambiorix::Routing$get_middleware()`
- `ambiorix::Routing$get_params()`
- `ambiorix::Routing$get_receivers()`
- `ambiorix::Routing$get_routes()`
- `ambiorix::Routing$param()`
- `ambiorix::Routing$prepare()`
- `ambiorix::Routing$receive()`
- `ambiorix::Routing$use()`

}} \if{html}{\out{

}} \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-Router-new}{}}} \subsection{Method \code{new()}}{ \subsection{Usage}{ \if{html}{\out{
}}\preformatted{Router$new(path)}\if{html}{\out{
}} } \subsection{Arguments}{ \if{html}{\out{
}} \describe{ \item{\code{path}}{The base path of the router.} } \if{html}{\out{
}} } \subsection{Details}{ Define the base route. } } \if{html}{\out{

}} \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-Router-print}{}}} \subsection{Method \code{print()}}{ \subsection{Usage}{ \if{html}{\out{
}}\preformatted{Router$print()}\if{html}{\out{
}} } \subsection{Details}{ Print } } \if{html}{\out{

}} \if{html}{\out{}} \if{latex}{\out{\hypertarget{method-Router-clone}{}}} \subsection{Method \code{clone()}}{ The objects of this class are cloneable with this method. \subsection{Usage}{ \if{html}{\out{
}}\preformatted{Router$clone(deep = FALSE)}\if{html}{\out{
}} } \subsection{Arguments}{ \if{html}{\out{
}} \describe{ \item{\code{deep}}{Whether to make a deep clone.} } \if{html}{\out{
}} } } }