@@ -5,10 +9,6 @@ SPDX-FileCopyrightText: 2021 Andrea Pappacoda
...
@@ -5,10 +9,6 @@ SPDX-FileCopyrightText: 2021 Andrea Pappacoda
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0
-->
-->
---
title: Asynchronous HTTP programming
---
Interfaces provided by Pistaches are _asynchronous_ and _non-blocking_. Asynchronous programming allows for code to continue executing even if the result of a given call is not available yet. Calls that provide an asynchronous interface are referred to _asynchronous calls_.
Interfaces provided by Pistaches are _asynchronous_ and _non-blocking_. Asynchronous programming allows for code to continue executing even if the result of a given call is not available yet. Calls that provide an asynchronous interface are referred to _asynchronous calls_.
An example of such a call is the `send()` function provided by the `ResponseWriter` interface. This function returns the number of bytes written to the socket file descriptor associated to the connection. However, instead of returning directly the value to the caller and thus blocking the caller, it wraps the value into a component called a `Promise`.
An example of such a call is the `send()` function provided by the `ResponseWriter` interface. This function returns the number of bytes written to the socket file descriptor associated to the connection. However, instead of returning directly the value to the caller and thus blocking the caller, it wraps the value into a component called a `Promise`.
@@ -5,10 +9,6 @@ SPDX-FileCopyrightText: 2021 Andrea Pappacoda
...
@@ -5,10 +9,6 @@ SPDX-FileCopyrightText: 2021 Andrea Pappacoda
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0
-->
-->
---
title: Headers
---
## Overview
## Overview
Inspired by the [Rust](https://www.rust-lang.org) eco-system and [Hyper](https://hyper.rs), HTTP headers are represented as _type-safe_ plain objects. Instead of representing headers as a pair of `(key: string, value: value)`, the choice has been made to represent them as plain objects. This greatly reduces the risk of typo errors that can not catched by the compiler with plain old strings.
Inspired by the [Rust](https://www.rust-lang.org) eco-system and [Hyper](https://hyper.rs), HTTP headers are represented as _type-safe_ plain objects. Instead of representing headers as a pair of `(key: string, value: value)`, the choice has been made to represent them as plain objects. This greatly reduces the risk of typo errors that can not catched by the compiler with plain old strings.
@@ -5,11 +10,6 @@ SPDX-FileCopyrightText: 2021 Andrea Pappacoda
...
@@ -5,11 +10,6 @@ SPDX-FileCopyrightText: 2021 Andrea Pappacoda
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0
-->
-->
---
id: http-handler
title: HTTP handler
---
Requests that are received by Pistache are handled by a special class called `Http::Handler`. This class declares a bunch of virtual methods that can be overriden to handle special events that occur on the socket and/or connection.
Requests that are received by Pistache are handled by a special class called `Http::Handler`. This class declares a bunch of virtual methods that can be overriden to handle special events that occur on the socket and/or connection.
The `onRequest()` function must be overriden. This function is called whenever Pistache received data and correctly parsed it as an HTTP request.
The `onRequest()` function must be overriden. This function is called whenever Pistache received data and correctly parsed it as an HTTP request.
@@ -5,8 +9,4 @@ SPDX-FileCopyrightText: 2021 Andrea Pappacoda
...
@@ -5,8 +9,4 @@ SPDX-FileCopyrightText: 2021 Andrea Pappacoda
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0
-->
-->
---
title: REST description
---
Documentation writing for this part is still in progress, please refer to the [rest_description](https://github.com/pistacheio/pistache/blob/master/examples/rest_description.cc) example.
Documentation writing for this part is still in progress, please refer to the [rest_description](https://github.com/pistacheio/pistache/blob/master/examples/rest_description.cc) example.
@@ -5,10 +9,6 @@ SPDX-FileCopyrightText: 2021 Andrea Pappacoda
...
@@ -5,10 +9,6 @@ SPDX-FileCopyrightText: 2021 Andrea Pappacoda
SPDX-License-Identifier: Apache-2.0
SPDX-License-Identifier: Apache-2.0
-->
-->
---
title: Routing
---
HTTP routing consists of binding an HTTP route to a C++ callback. A special component called an HTTP router will be in charge of dispatching HTTP requests to the right C++ callback. A route is composed of an HTTP verb associated to a resource:
HTTP routing consists of binding an HTTP route to a C++ callback. A special component called an HTTP router will be in charge of dispatching HTTP requests to the right C++ callback. A route is composed of an HTTP verb associated to a resource: