These handlers are called before the request body has been recieved and lets y ou preemptively reject requests before recieving their full content. Most of your logic, however, will be in the main handlers and you are asked to consult the api_request_handlers docs for in-depth details on how to use request handlers in general.
Usage
api_get_header(
api,
path,
handler,
serializers = NULL,
parsers = NULL,
use_strict_serializer = FALSE,
download = FALSE,
route = NULL
)
api_head_header(
api,
path,
handler,
serializers = NULL,
parsers = NULL,
use_strict_serializer = FALSE,
download = FALSE,
route = NULL
)
api_post_header(
api,
path,
handler,
serializers = NULL,
parsers = NULL,
use_strict_serializer = FALSE,
download = FALSE,
route = NULL
)
api_put_header(
api,
path,
handler,
serializers = NULL,
parsers = NULL,
use_strict_serializer = FALSE,
download = FALSE,
route = NULL
)
api_delete_header(
api,
path,
handler,
serializers = NULL,
parsers = NULL,
use_strict_serializer = FALSE,
download = FALSE,
route = NULL
)
api_connect_header(
api,
path,
handler,
serializers = NULL,
parsers = NULL,
use_strict_serializer = FALSE,
download = FALSE,
route = NULL
)
api_options_header(
api,
path,
handler,
serializers = NULL,
parsers = NULL,
use_strict_serializer = FALSE,
download = FALSE,
route = NULL
)
api_trace_header(
api,
path,
handler,
serializers = NULL,
parsers = NULL,
use_strict_serializer = FALSE,
download = FALSE,
route = NULL
)
api_patch_header(
api,
path,
handler,
serializers = NULL,
parsers = NULL,
use_strict_serializer = FALSE,
download = FALSE,
route = NULL
)
api_any_header(
api,
path,
handler,
serializers = NULL,
parsers = NULL,
use_strict_serializer = FALSE,
download = FALSE,
route = NULL
)
Arguments
- api
A plumber2 api object to add the handler to
- path
A string giving the path the handler responds to. See Details
- handler
A handler function to call when a request is matched to the path
- serializers
A named list of serializers that can be used to format the response before sending it back to the client. Which one is selected is based on the request
Accept
header. Seeget_serializers()
for a helper to construct this- parsers
A named list of parsers that can be used to parse the request body before passing it in as the
body
argument. Which one is selected is based on the requestContent-Type
header. Seeget_parsers()
for a helper to construct this- use_strict_serializer
By default, if a serializer that respects the requests
Accept
header cannot be found, then the first of the provided ones are used. Setting this toTRUE
will instead send back a406 Not Acceptable
response- download
Should the response mark itself for download instead of being shown inline? Setting this to
TRUE
will set theContent-Disposition
header in the response toattachment
. Setting it to a string is equivalent to setting it toTRUE
but will in addition also set the default filename of the download to the string value- route
The route this handler should be added to. Defaults to the last route in the stack. If the route does not exist it will be created as the last route in the stack
See also
Other Request Handlers:
api_request_handlers