How sukalen/mytinywebserver works
myTinyWebserver is a multithreaded, epoll-based HTTP server with static pages, authentication, and a cat-finding game API. The main workflow accepts a client request, parses and routes it, then serves a file or invokes the relevant service; game requests generate or update a session and return a JSON snapshot. The README documents reactor handling, worker threads, connection timeouts, and logging. Sampled sources establish game and authentication behavior; some HTTP dispatch and runtime wiring are inferred from the documented decomposition and partial main excerpt, so uncertain links are omitted.
Main entry points: http_conn.cpp HTTP connection · main.cpp Server event loop · game_service.cpp Game service · auth_service.cpp Auth service
Components 21
Server runtime
- Server event loop
main.cpp - Worker pool
threadpool/threadpool.h - Connection timers
timer/lst_timer.h - Logging
log/log.cpp
HTTP handling
- HTTP connection
http/http_conn.cpp - Request parser
http/http_request.cpp - Router
http/router.cpp - HTTP response
http/http_response.cpp - Static files
http/static_file_handler.cpp - Auth handling
http/http_conn.cpp - Game API
http/game_api_handler.cpp
Game domain
- Game service
service/game_service.cpp - Session registry
service/game_service.cpp - Game session
game/game_session.cpp - Level generator
game/level_generator.cpp - Game rules
game/game_rule.cpp
Authentication and storage
- Auth service
service/auth_service.cpp - SQL connection pool
CGImysql/sql_connection_pool.cpp
Other components
- Web client
- Document root
- MySQL database
Connections 21
- Web client → Server event loop: sends request
- Server event loop → HTTP connection: initializes connections
- Server event loop → Worker pool: dispatches work
- Server event loop → Connection timers: manages timeouts
- Server event loop → Auth service: loads users
- HTTP connection → Request parser: parses bytes
- HTTP connection → Router: resolves route
- HTTP connection → Static files: loads file
- HTTP connection → Auth handling: handles auth
- HTTP connection → Game API: dispatches API
- HTTP connection → HTTP response: builds response
- Static files → Document root: reads file
- Game API → Game service: invokes operation
- Game service → Level generator: generates level
- Game service → Session registry: stores and finds
- Game service → Game session: updates or reads
- Game session → Game rules: validates level
- Auth service → SQL connection pool: acquires connection
- SQL connection pool → MySQL database: queries
- Auth service → MySQL database: reads and writes users
- Server event loop → Logging: records events