---
title: "ClikaRT::http::ServerRequest"
sidebar_label: "ServerRequest"
description: "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 handl…"
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--class">class</span>

**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`](./ServerRequest.md#path) / [`body`](./ServerRequest.md#body) / [`client_ip`](./ServerRequest.md#client_ip)) point into request-owned storage with the same lifetime.

## Member functions

### ServerRequest() {#ServerRequest}

<div class="api-signature">

**`ServerRequest`**(`ServerRequest&&`) `noexcept`

</div>

Move-only: transfers the request handle.

<div class="api-declared">

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

</div>

### operator=() {#operator-assign}

<div class="api-signature">

[`ServerRequest`](./ServerRequest.md)`&` **`operator=`**([`ServerRequest`](./ServerRequest.md)`&&`) `noexcept`

</div>

Move-assign: transfers the request handle.

<div class="api-declared">

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

</div>

### \~ServerRequest() {#ServerRequest-2}

<div class="api-signature">

**`~ServerRequest`**()

</div>

Releases the request.

<div class="api-declared">

Declared in `ClikaRT/http/server.h`, line 110

</div>

### method() {#method}

<div class="api-signature">

[`Method`](./index.md#Method) **`method`**() `const`

</div>

the HTTP verb

<div class="api-declared">

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

</div>

### path() {#path}

<div class="api-signature">

`std::string_view` **`path`**() `const`

</div>

decoded path (no query string)

<div class="api-declared">

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

</div>

### body() {#body}

<div class="api-signature">

`std::string_view` **`body`**() `const`

</div>

raw request bytes

<div class="api-declared">

Declared in `ClikaRT/http/server.h`, line 115

</div>

### client\_ip() {#client_ip}

<div class="api-signature">

`std::string_view` **`client_ip`**() `const`

</div>

peer socket address (not spoofable via headers)

<div class="api-declared">

Declared in `ClikaRT/http/server.h`, line 116

</div>

### should\_stop() {#should_stop}

<div class="api-signature">

`bool` **`should_stop`**() `const`

</div>

connection closed / server stopping

<div class="api-declared">

Declared in `ClikaRT/http/server.h`, line 117

</div>

### header() {#header}

<div class="api-signature">

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

</div>

case-insensitive

<div class="api-declared">

Declared in `ClikaRT/http/server.h`, line 120

</div>

### query() {#query}

<div class="api-signature">

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

</div>

?k=v (first value)

<div class="api-declared">

Declared in `ClikaRT/http/server.h`, line 121

</div>

### cookie() {#cookie}

<div class="api-signature">

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

</div>

from the [Cookie](./Cookie.md) header

<div class="api-declared">

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

</div>

### query\_all() {#query_all}

<div class="api-signature">

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

</div>

all values for ?k=…

<div class="api-declared">

Declared in `ClikaRT/http/server.h`, line 123

</div>

### form\_field() {#form_field}

<div class="api-signature">

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

</div>

text field by name

<div class="api-declared">

Declared in `ClikaRT/http/server.h`, line 127

</div>

### form\_file() {#form_file}

<div class="api-signature">

`std::optional<`[`FormFile`](./FormFile.md)`>` **`form_file`**(`std::string_view` `name`) `const`

</div>

file part by name

<div class="api-declared">

Declared in `ClikaRT/http/server.h`, line 128

</div>

### form\_parts() {#form_parts}

<div class="api-signature">

`std::vector<`[`FormPart`](./FormPart.md)`>` **`form_parts`**() `const`

</div>

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

<div class="api-declared">

Declared in `ClikaRT/http/server.h`, line 131

</div>

### param\_count() {#param_count}

<div class="api-signature">

`std::size_t` **`param_count`**() `const`

</div>

number of path captures on the matched route

<div class="api-declared">

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

</div>

### param(size\_t) {#param}

<div class="api-signature">

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

</div>

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

<div class="api-declared">

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

</div>

### param(string\_view) {#param-2}

<div class="api-signature">

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

</div>

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

**Throws**

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

<div class="api-declared">

Declared in `ClikaRT/http/server.h`, line 143

</div>

### set\_attr() {#set_attr}

<div class="api-signature">

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

</div>

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

<div class="api-declared">

Declared in `ClikaRT/http/server.h`, line 148

</div>

### attr() {#attr}

<div class="api-signature">

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

</div>

Read a request attribute set by [`set_attr`](./ServerRequest.md#set_attr); nullopt when absent.

<div class="api-declared">

Declared in `ClikaRT/http/server.h`, line 150

</div>
