Skip to content

Latest commit

 

History

History
59 lines (32 loc) · 3.5 KB

GETTING_STARTED.md

File metadata and controls

59 lines (32 loc) · 3.5 KB

Getting Started

Welcome to the main documentation page of the ZIAPI. The ZIAPI is a set of interfaces and concrete implementations to help you manage module implementation for the Zia project.

Introduction

ZIAPI aims at making your life easier as a developper. It features different type of modules that you can implement to customize parts of your Zia project.

Here is an overview of what you can do using the ZIAPI module interfaces:

  • Switch between HTTP versions 1.0, 1.1, 2 and 3
  • Change the underlying network implementation (UDP, TCP, Quic, ...)
  • Change the behaviour of your HTTP server (Directory Listing, PHP CGI)
  • Manage multiple sites and conditional module execution (e.g. only execute a module on a request if it is a GET request)

Architecture

To understand how the ZiAPI works, lets take a look at how requests are handled from start to finish.

Request handling process

The request / response cycle is handled in 5 steps. Before we go into detail about how each of the steps work let's look at a quick illustration to help us understand better.

Request / Response flow

Okay now, let's study each step in detail.

Step 1. Receive

Like any HTTP message, the request is first handled through the network layer (TCP sockets, etc...). This is where you'll setup your sockets and listeners, your hypothetical SSL / TLS encryption logic, your HTTP parser and any additional serialization / deserialization code. When a request arrives, the networking layer must read it, decrypt it, parse it and forward it to the next layer: the pre-processing layer!

Check the module associated with this step here

Step 2. Pre-process

Okay, so our request has been received and parsed by the network layer. Once it lands in the pre-processing layer, a pipeline of request pre-processing modules will be invoked. This is where you can route the request, log it, rewrite its URL, add / remove some headers, etc.

Check the module associated with this step here

Step 3. Handle

Once the whole pre-processing pipeline has been applied on the request, the corresponding handler for this request is invoked. A handler will generate the HTTP response for a request. So that might be the contents of a file (Directory Listing module), the output of a PHP script (PHP CGI) or some JSON output gathered from a database, you choose!

Check the module associated with this step here

Step 4. Post-process

Once the HTTP response has been generated by the handling layer, it is forwarded to the post-processing layer. This is where a pipeline of response post-processing modules will be invoked. This is where you can serialize the contents of your response body, log the response, add additional headers such as CORS, etc.

Check the module associated with this step here

Step 5. Send

Once the post-processing pipeline has been applied on the response, it is forwarded back to the network layer to be sent back over the network. This is where you will serialize your HTTP message, and possibly encode it using TLS before writing it to your socket.

Check the module associated with this step here

And boom! Request handled! Using 5 easy steps: Receive, pre-process, handle, post process and send.

For more information checkout the documentation entrypoint.