|
Csilk 0.2.1
A lightweight, high-performance C HTTP web framework
|
Example using the high-level csilk_app_t API. More...
#include <stdbool.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <time.h>#include "csilk/app/app.h"#include "csilk/csilk.h"#include "csilk/reflection/reflect.h"
Data Structures | |
| struct | reflect_address_t |
| Nested address type. More... | |
| struct | reflect_user_t |
| Complex user profile with nested structs, arrays, and mixed types. More... | |
| struct | reflect_order_item_t |
| Order item inside a nested array. More... | |
| struct | reflect_order_t |
| Full order with nested items array via struct fields. More... | |
Macros | |
| #define | REFLECT_ADDRESS_MAP(_, ...) |
| #define | REFLECT_USER_MAP(_, ...) |
| #define | REFLECT_ORDER_ITEM_MAP(_, ...) |
| #define | REFLECT_ORDER_MAP(_, ...) |
Functions | |
| static void | hello (csilk_ctx_t *c) |
| Handler for GET / — "Hello from csilk easy API!". | |
| static void | user (csilk_ctx_t *c) |
| Handler for GET /user/:id — returns the user ID from path param. | |
| static void | ping (csilk_ctx_t *c) |
| Handler for GET /ping — returns a JSON status response. | |
| static void | login (csilk_ctx_t *c) |
| Handler for POST /login — authenticates user and returns a token. | |
| static void | echo (csilk_ctx_t *c) |
| Handler for GET /echo?msg=... — echoes back the query parameter. | |
| static void | create_user (csilk_ctx_t *c) |
| Handler for POST /api/users — creates a user via reflection binding. Accepts JSON body with nested address, arrays, booleans, etc. | |
| static void | get_user (csilk_ctx_t *c) |
| Handler for GET /api/users/:id — returns a user profile via reflection. | |
| static void | create_order (csilk_ctx_t *c) |
| Handler for POST /api/orders — creates an order via reflection binding. | |
| static void | get_order (csilk_ctx_t *c) |
| Handler for GET /api/orders/:id — returns a mock order via reflection. | |
| static void | sse_handler (csilk_ctx_t *c) |
| Handler for GET /stream — SSE connection demo. | |
| static void | timer_mw (csilk_ctx_t *c) |
| Custom middleware — measures and logs request processing time. | |
| int | main (void) |
Example using the high-level csilk_app_t API.
Demonstrates csilk_app_new, reflection binding, nested structs, arrays, route groups, SSE, gzip, and Swagger UI.
| struct reflect_address_t |
| struct reflect_user_t |
Complex user profile with nested structs, arrays, and mixed types.

| Data Fields | ||
|---|---|---|
| bool | active | |
| reflect_address_t | address | |
| char * | bio | |
| char | email[128] | |
| uint8_t | flags[4] | |
| int64_t | id | |
| int16_t | level | |
| char | name[64] | |
| float | rating | |
| double | score | |
| struct reflect_order_item_t |
| struct reflect_order_t |
Full order with nested items array via struct fields.

| Data Fields | ||
|---|---|---|
| char | customer_email[128] | |
| reflect_order_item_t | items[3] | |
| char | notes[256] | |
| int64_t | order_id | |
| double | total | |
| #define REFLECT_ADDRESS_MAP | ( | _, | |
| ... | |||
| ) |
| #define REFLECT_ORDER_ITEM_MAP | ( | _, | |
| ... | |||
| ) |
| #define REFLECT_ORDER_MAP | ( | _, | |
| ... | |||
| ) |
| #define REFLECT_USER_MAP | ( | _, | |
| ... | |||
| ) |
|
static |
Handler for POST /api/orders — creates an order via reflection binding.
|
static |
Handler for POST /api/users — creates a user via reflection binding. Accepts JSON body with nested address, arrays, booleans, etc.
|
static |
Handler for GET /echo?msg=... — echoes back the query parameter.
|
static |
Handler for GET /api/orders/:id — returns a mock order via reflection.
|
static |
Handler for GET /api/users/:id — returns a user profile via reflection.
|
static |
Handler for GET / — "Hello from csilk easy API!".
|
static |
Handler for POST /login — authenticates user and returns a token.
| int main | ( | void | ) |
|
static |
Handler for GET /ping — returns a JSON status response.
|
static |
Handler for GET /stream — SSE connection demo.
|
static |
Custom middleware — measures and logs request processing time.
|
static |
Handler for GET /user/:id — returns the user ID from path param.