doompanning/docs/man/nng_http_server_set_error_page.3http.adoc
oxmox 7063e2102e Squashed 'external/nng/' content from commit 29b73962
git-subtree-dir: external/nng
git-subtree-split: 29b73962b939a6fbbf6ea8d5d7680bb06d0eeb99
2024-12-18 18:29:29 +01:00

69 lines
2.3 KiB
Text

= nng_http_server_set_error_page(3http)
//
// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This document is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt). A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//
== NAME
nng_http_server_set_error_page - set custom HTTP error page
== SYNOPSIS
[source, c]
----
#include <nng/nng.h>
#include <nng/supplemental/http/http.h>
int nng_http_server_set_error_page(nng_http_server *server,
uint16_t code, const char *html);
----
== DESCRIPTION
The `nng_http_server_set_error_page()` sets an error page to be used
for HTTP status _code_ on the server instance _server_.
The body content of the HTTP responses will contain _html_.
The custom HTML content will be used when the server is returning an
internally generated error response, or is returning an error response
that was allocated with the
xref:nng_http_res_alloc_error.3http.adoc[`nng_http_res_alloc_error()`]
function.
This HTML content will also be used if the application calls the
xref:nng_http_server_res_error.3http.adoc[`nng_http_server_res_error()`].
The last custom error page set for _code_ by either this function or
xref:nng_http_server_set_error_file.3http.adoc[`nng_http_server_error_file()`]
will be used.
NOTE: Error responses that have their body content changed after allocation,
or that are written directly by the application, will not use the body
content supplied here.
The supplied HTML content is copied by this function, and may be reused
after this function returns.
== RETURN VALUES
This function returns 0 on success, and non-zero otherwise.
== ERRORS
[horizontal]
`NNG_ENOMEM`:: Insufficient free memory exists.
`NNG_ENOTSUP`:: HTTP not supported.
== SEE ALSO
[.text-left]
xref:nng_http_res_alloc_error.3http.adoc[nng_http_res_alloc_error(3http)],
xref:nng_http_server_hold.3http.adoc[nng_http_server_hold(3http)],
xref:nng_http_server_res_error.3http.adoc[nng_http_server_res_error(3http)],
xref:nng_http_server_set_error_file.3http.adoc[nng_http_server_set_error_file(3http)],
xref:nng_strerror.3.adoc[nng_strerror(3)],
xref:nng.7.adoc[nng(7)]