{{- /*gotype: r00t2.io/clientinfo/server.Page*/ -}} {{- define "usage" }} {{- $page := . -}} {{- $linkico := "🔗" }} {{- template "meta.top" $page }}
You can control how the main page displays/renders.
By default, it will try to "guess" what you want; e.g. if you access it in Chrome, it will return HTML but if you fetch via Curl, you'll get raw JSON
(or your specified data format; see below). If the classification of client can't be determined and an Accept
wasn't specified,
a fallback to text-mode (by default application/json
) will be returned.
You can force a specific raw output by specifying the MIME type via
the Accept
header (RFC 9110 § 12.5.1), which may be one of:
application/json
for JSON (RFC 8259, IANA registration)application/xml
for XML (RFC 7303, IANA registration)application/yaml
for YAML (RFC 9512, IANA registration)text/html
for HTML (RFC 2854, IANA registration)Accept: application/json
will return JSON.
application/json
.
text/html
may be used to force an HTML response from a text-only client,
just as one of the application/*
MIME types above may be used to force that "raw" text MIME type for a "graphical" browser client.
The specification as defined by RFC 9110 § 12.5.1 is completely
valid to pass and will be parsed without error (provided the header value is RFC-compliant and IANA-compliant),
though note that application/xml
and text/html
's charset
parameter will be entirely ignored;
the returned XML/HTML is always Unicode (with UTF-8 encoding).
Accept
was given, an error will be returned; specifically, a
406
status code (RFC 9110 § 15.5.7).
In this case, supported MIME types will be returned in the response's Accept
header values, e.g.:
Accept: application/json Accept: application/xml Accept: application/yaml Accept: text/htmlNote that Links, Lynx, Elinks, and W3M are considered "graphical" browsers by this program as they are HTML-centric.
The following parameters control/modify behavior.{{ $linkico }}
mime
: Specify an explicit MIME type via URL instead of the Accept
header as specified above.
Accept
is more performant.?mime=application/json
).Accept
header is specified, the URL query takes preference.include
: Include a <code>
(or <pre>
, depending on if indentation is needed/requested) block in the HTML for the specified MIME type as well.mime
parameter/Accept
header.
include
may not be text/html
; it will be ignored if this is set. Just learn to ctrl+u
.indent
: Enable/specify indentation for JSON and XML output; ignored for others.
\t
, 0x09
) for each level, use ?indent=%09
?indent
), the default is two
spaces (0x20
); this would be represented
as ?indent=%20%20
?indent=
(no value specified) is equal to ?indent
.