Skip to main content

ClikaRT::http::ServerRequest

class

Header: ClikaRT/http/server.h

A request as seen by a handler / middleware. A borrowed handle: it is valid only for the duration of the handler call and does NOT own the underlying request; never store it or use it after your handler returns. The view-returning observers (path / body / client_ip) point into request-owned storage with the same lifetime.

Member functions

ServerRequest()

ServerRequest(ServerRequest&&) noexcept

Move-only: transfers the request handle.

Declared in ClikaRT/http/server.h, line 97

operator=()

ServerRequest& operator=(ServerRequest&&) noexcept

Move-assign: transfers the request handle.

Declared in ClikaRT/http/server.h, line 99

~ServerRequest()

~ServerRequest()

Releases the request.

Declared in ClikaRT/http/server.h, line 101

method()

Method method() const

the HTTP verb

Declared in ClikaRT/http/server.h, line 104

path()

std::string_view path() const

decoded path (no query string)

Declared in ClikaRT/http/server.h, line 105

body()

std::string_view body() const

raw request bytes

Declared in ClikaRT/http/server.h, line 106

client_ip()

std::string_view client_ip() const

peer socket address (not spoofable via headers)

Declared in ClikaRT/http/server.h, line 107

should_stop()

bool should_stop() const

connection closed / server stopping

Declared in ClikaRT/http/server.h, line 108

std::optional<std::string> header(std::string_view name) const

case-insensitive

Declared in ClikaRT/http/server.h, line 111

query()

std::optional<std::string> query(std::string_view name) const

?k=v (first value)

Declared in ClikaRT/http/server.h, line 112

std::optional<std::string> cookie(std::string_view name) const

from the Cookie header

Declared in ClikaRT/http/server.h, line 113

query_all()

std::vector<std::string> query_all(std::string_view name) const

all values for ?k=…

Declared in ClikaRT/http/server.h, line 114

form_field()

std::optional<std::string> form_field(std::string_view name) const

text field by name

Declared in ClikaRT/http/server.h, line 118

form_file()

std::optional<FormFile> form_file(std::string_view name) const

file part by name

Declared in ClikaRT/http/server.h, line 119

form_parts()

std::vector<FormPart> form_parts() const

Every part of a multipart body (text fields + file parts, repeated names kept). Empty when the request is not multipart/form-data.

Declared in ClikaRT/http/server.h, line 122

param_count()

std::size_t param_count() const

number of path captures on the matched route

Declared in ClikaRT/http/server.h, line 125

param(size_t)

std::string param(std::size_t index) const

A path capture by 0-based index, or by name for a (?P<name>...) group. Raises ClikaRT::Error (NotFound) when the index / name has no capture (e.g. a non-pattern route).

Declared in ClikaRT/http/server.h, line 130

param(string_view)

std::string param(std::string_view name) const

The named form: the capture of a (?P<name>...) group on the matched route.

Throws

  • ClikaRT::Error: (NotFound) when no such named capture exists.

Declared in ClikaRT/http/server.h, line 134

set_attr()

void set_attr(std::string_view name, std::string_view value)

Attach a per-request attribute (namevalue), the middleware → handler hand-off channel.

Declared in ClikaRT/http/server.h, line 139

attr()

std::optional<std::string> attr(std::string_view name) const

Read a request attribute set by set_attr; nullopt when absent.

Declared in ClikaRT/http/server.h, line 141