![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include "nilorea/n_common.h"#include "nilorea/n_http_router.h"#include "nilorea/n_log.h"Go to the source code of this file.
Functions | |
| static void | expect_route (const N_ROUTER *r, n_http_req_method method, const char *path, const char *want, N_ROUTE_MATCH *m) |
| route path with method and expect a route data tag (NULL: not found) | |
| static void | expect_true (const char *what, int ok) |
| count a failed check | |
| static int | h (void *ctx, const N_ROUTE_MATCH *m) |
| a handler that does nothing (the test only routes) | |
| int | main (int argc, char **argv) |
| run the checks | |
| static int | param_is (const N_ROUTE_MATCH *m, const char *name, const char *want) |
| param name of the last match equals want | |
| static int | process_args (int argc, char **argv) |
| read -V | |
| static void | test_checks (void) |
| the start-up checks | |
| static void | test_match (const N_ROUTER *r) |
| matching on the blog's tables | |
Variables | |
| static const N_ROUTE | ADMIN [] |
| a few admin routes | |
| static int | failures = 0 |
| failed checks | |
| static int | log_level = 3 |
| log level from -V | |
| static const N_ROUTE | PUBLIC [] |
| the public routes of the Nilorea blog, in a deliberately unhelpful order: the catch-all "/{slug}/" comes first | |
|
static |
route path with method and expect a route data tag (NULL: not found)
| r | router |
| method | method |
| path | the path |
| want | expected data tag |
| m | receives the match |
Definition at line 114 of file ex_http_router.c.
References N_ROUTE::data, failures, LOG_ERR, n_log, N_ROUTER_FOUND, n_router_match(), N_ROUTER_NOT_FOUND, and N_ROUTE_MATCH::route.
Referenced by test_match().
|
static |
|
static |
a handler that does nothing (the test only routes)
| ctx | unused |
| m | unused |
Definition at line 77 of file ex_http_router.c.
Referenced by _a4_item_at(), _a4_item_rect(), _civil_to_time(), _cookie_scan(), _curve_draw(), _draw_label_lines(), _draw_rows_scrollbar(), _draw_scrollbar_thumb(), _draw_textarea(), _draw_themed_rect(), _global_scroll_needs(), _label_lines_char_at(), _label_lines_top(), _mp_part_headers(), _n_dc_walk(), _n_gui_apply_display_size(), _new_widget(), _ngui_meas_slot(), _popup_row_at(), _resp_cat(), _sha256_block(), _suggest_panel_rect(), _text_dims(), _tile_covers_height(), _wheel_geometry(), _win_auto_sb_rects(), background(), build_panel(), count_pixels_differing(), demo_astar(), demo_astar_standalone(), demo_dead_reckoning(), demo_iso_engine(), draw_background(), draw_cell(), draw_into(), draw_particle(), element_value(), find_hdr(), fmix32(), gfx_mode(), h2_on_request(), handle_inline_and_count(), hdr_has(), head_is(), heap_free(), heap_grow(), heap_new(), heap_pop(), heap_push(), ink(), is_http_url(), iso_map_build_draw_order(), iso_map_draw(), iso_map_get_visible_edges(), iso_map_get_visible_edges_segment(), iso_map_set_height(), iso_map_smooth_corner_heights(), iso_map_to_screen(), iso_map_to_screen_f(), iso_screen_to_map_height(), iso_screen_to_map_height_f(), lexMenuRun(), main(), main(), main(), make_png(), match_heading(), md_run(), md_table(), n_entropy_positions(), n_entropy_shannon(), n_gui_add_button(), n_gui_add_button_bitmap(), n_gui_add_checkbox(), n_gui_add_combobox(), n_gui_add_custom(), n_gui_add_datagrid(), n_gui_add_dropmenu(), n_gui_add_hexview(), n_gui_add_image(), n_gui_add_label(), n_gui_add_label_link(), n_gui_add_listbox(), n_gui_add_markdownview(), n_gui_add_progressbar(), n_gui_add_radiolist(), n_gui_add_scrollbar(), n_gui_add_slider(), n_gui_add_splitpane(), n_gui_add_syntaxview(), n_gui_add_textarea(), n_gui_add_toggle_button(), n_gui_add_vslider(), n_gui_add_window(), n_gui_colorwheel_hue(), n_gui_colorwheel_new(), n_gui_curve_eval_points(), n_gui_curve_new(), n_gui_draw_color_swatch(), n_gui_grid_cell_rect(), n_gui_grid_set_rect(), n_gui_label_fits(), n_gui_set_display_size(), n_gui_set_virtual_size(), n_gui_tree_create(), n_gui_widget_screen_rect(), n_gui_widget_set_rect(), n_gui_window_button_rect(), n_gui_window_set_rect(), n_gui_window_set_rect_axes(), n_http_request_header(), n_http_request_header_count(), n_http_response_head(), n_time_parse_http_date(), n_time_parse_rfc3339(), n_wrap_index_at(), on_ghost_toggle(), on_player_toggle(), on_request(), peer_headers(), print_map_ascii(), randomize_map(), set_gfx_mode(), stretch_sprite(), test_checks(), test_headers(), test_read(), test_sha256_hex(), worker_handle_client(), wrap_hit_line(), and write_zip().
| int main | ( | int | argc, |
| char ** | argv ) |
run the checks
| argc | argument count |
| argv | arguments |
Definition at line 273 of file ex_http_router.c.
References ADMIN, expect_true(), failures, LOG_ERR, log_level, LOG_NOTICE, n_log, n_router_add(), n_router_check(), n_router_count(), n_router_free(), n_router_new(), n_router_route(), process_args(), PUBLIC, set_log_level(), test_checks(), and test_match().
|
static |
param name of the last match equals want
| m | the match |
| name | placeholder |
| want | expected decoded value |
Definition at line 129 of file ex_http_router.c.
References n_route_param().
Referenced by test_match().
|
static |
read -V
| argc | argument count |
| argv | arguments |
Definition at line 60 of file ex_http_router.c.
References log_level.
|
static |
the start-up checks
Definition at line 208 of file ex_http_router.c.
References expect_true(), failures, h(), LOG_ERR, n_log, N_ROUTE_GET, N_ROUTE_HEAD, N_ROUTE_POST, n_router_add(), n_router_check(), n_router_count(), n_router_free(), and n_router_new().
Referenced by main().
|
static |
matching on the blog's tables
Definition at line 136 of file ex_http_router.c.
References expect_route(), expect_true(), N_HTTP_REQ_GET, N_HTTP_REQ_HEAD, N_HTTP_REQ_POST, N_ROUTE_GET, N_ROUTE_HEAD, n_route_param(), N_ROUTE_POST, n_router_allow_header(), N_ROUTER_BAD_REQUEST, n_router_match(), N_ROUTER_METHOD_NOT_ALLOWED, N_ROUTER_NOT_FOUND, N_ROUTE_MATCH::nb_params, and param_is().
Referenced by main().
|
static |
a few admin routes
Definition at line 101 of file ex_http_router.c.
Referenced by main().
|
static |
failed checks
Definition at line 42 of file ex_http_router.c.
|
static |
log level from -V
Definition at line 40 of file ex_http_router.c.
|
static |
the public routes of the Nilorea blog, in a deliberately unhelpful order: the catch-all "/{slug}/" comes first
Definition at line 85 of file ex_http_router.c.
Referenced by main().