ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
http_route.h File Reference

The route table: where a request goes. More...

Go to the source code of this file.

Classes

struct  HttpRoute
 Internal route entry stored in the routing table. More...
 
struct  HttpRouteNs
 Dispatch table. Addressed by offset, so the layout is asserted below. More...
 

Typedefs

typedef struct HttpRoute HttpRoute
 Internal route entry stored in the routing table.
 
typedef struct HttpRouteCtx HttpRouteCtx
 The table's storage. Declared, never defined here: the layout stays in route.c.
 

Enumerations

enum  HttpRouteType { ROUTE_HTTP }
 Discriminates between HTTP, WebSocket, and SSE route entries. More...
 

Functions

 PROTOCORE_NS_LAYOUT (HttpRouteNs, add, count, at, reset)
 
HttpRoute * protocore_http_routes_add (uint8_t *work)
 Take the next free entry, zeroed and ready to fill, or NULL when .
 
uint8_t protocore_http_routes_count (uint8_t *work)
 Entries currently registered.
 
HttpRoute * protocore_http_routes_at (uint8_t *work, uint8_t i)
 Entry i, or NULL if i is past the end.
 
void protocore_http_routes_reset (uint8_t *work)
 Empty the table. For tests: a case that does not reset matches .
 
uint8_t * protocore_http_route_span (void)
 The bytes every entry here runs out of: the one route table.
 

Variables

PROTOCORE_NS HttpRouteNs HttpRoutes PROTOCORE_UNUSED
 Module namespace.
 

Detailed Description

The route table: where a request goes.

A row names a path pattern, a method, a handler, and the ws / sse / mount / credential id the request needs. Every one of those is HTTP, so the table sits under the HTTP root rather than at the network layer, which routes datagrams.

The module exports one symbol, HttpRoutes. Everything in route.c has internal linkage.

work is bytes the CALLER holds. This module reads none of them: it carries nothing between calls, so there is no state to keep and nothing to wipe. The parameter is there so a caller drives every namespace the same way.

Definition in file http_route.h.

Typedef Documentation

◆ HttpRoute

typedef struct HttpRoute HttpRoute

Internal route entry stored in the routing table.

Populated by on(), on_ws(), or on_sse(). Application code does not interact with this struct directly.

◆ HttpRouteCtx

typedef struct HttpRouteCtx HttpRouteCtx

The table's storage. Declared, never defined here: the layout stays in route.c.

Definition at line 96 of file http_route.h.

Enumeration Type Documentation

◆ HttpRouteType

Discriminates between HTTP, WebSocket, and SSE route entries.

Enumerator
ROUTE_HTTP 

Standard HTTP request/response.

Definition at line 32 of file http_route.h.

Function Documentation

◆ PROTOCORE_NS_LAYOUT()

PROTOCORE_NS_LAYOUT ( HttpRouteNs  ,
add  ,
count  ,
at  ,
reset   
)

◆ protocore_http_routes_add()

HttpRoute * protocore_http_routes_add ( uint8_t *  work)

Take the next free entry, zeroed and ready to fill, or NULL when .

Parameters
workPROTOCORE_HTTP_ROUTES_BORROW bytes the caller took. Not held past the call.
Returns
The HttpRoute *.

◆ protocore_http_routes_count()

uint8_t protocore_http_routes_count ( uint8_t *  work)

Entries currently registered.

Parameters
workPROTOCORE_HTTP_ROUTES_BORROW bytes the caller took. Not held past the call.
Returns
The uint8_t.

◆ protocore_http_routes_at()

HttpRoute * protocore_http_routes_at ( uint8_t *  work,
uint8_t  i 
)

Entry i, or NULL if i is past the end.

Parameters
workPROTOCORE_HTTP_ROUTES_BORROW bytes the caller took. Not held past the call.
iI
Returns
The HttpRoute *.

◆ protocore_http_routes_reset()

void protocore_http_routes_reset ( uint8_t *  work)

Empty the table. For tests: a case that does not reset matches .

Parameters
workPROTOCORE_HTTP_ROUTES_BORROW bytes the caller took. Not held past the call.

◆ protocore_http_route_span()

uint8_t * protocore_http_route_span ( void  )

The bytes every entry here runs out of: the one route table.

Stated beside the namespace rather than on it: an entry takes a borrow, and this is where that borrow comes from. Every registrar and every reader drives the same table, so the bytes belong to this module rather than to any one caller. Taken once from the end of the secure pool, which no mark and no release walks, so the table lasts the life of the program.

Returns
the span.

Variable Documentation

◆ PROTOCORE_UNUSED

PROTOCORE_NS HttpRouteNs HttpRoutes PROTOCORE_UNUSED
Initial value:
HttpRoute * protocore_http_routes_at(uint8_t *work, uint8_t i)
Entry i, or NULL if i is past the end.
uint8_t protocore_http_routes_count(uint8_t *work)
Entries currently registered.
void protocore_http_routes_reset(uint8_t *work)
Empty the table. For tests: a case that does not reset matches .
HttpRoute * protocore_http_routes_add(uint8_t *work)
Take the next free entry, zeroed and ready to fill, or NULL when .

Module namespace.

Definition at line 146 of file http_route.h.