readme.md (1591B)
1 # bunkum 2 3 A silly personal webserver with the goal to hand-roll basically whatever I can 4 (only dependencies are pthread, zlib, and libunwind). 5 6 Fun features include 7 - **Self-profiling**. If you pass a "Profile" header in any request, `bunkum` 8 will automatically profile itself as it serves the request and report the 9 profile info. This was remarkably painful to implement given weird quirks of 10 the ptrace() API for child threads. 11 - A **custom testing framework** with **automatic test discovery**. After 12 compiling the code as a dynamic library, It works by parsing the ELF file to 13 extract symbol names and find all of those that start with "test". As there's 14 an enforced test interface, it can then load the dynamic library and run the 15 tests. 16 - A custom **channel type** for inter-thread communications that is directly 17 implemented with atomic intrinsics 18 - A silly **PHF** for rapidly converting HTTP methods to their enum form 19 ```c 20 const enum http_method method_codes[] = { 21 DELETE, CONNECT, PUT, POST, TRACE, HEAD, OPTIONS, GET 22 }; 23 enum http_method method_enum(char* p) { 24 return method_codes[((*(uint64_t*)p*0x1b8b6e6d) % 0x100000000) >> 28]; 25 } 26 ``` 27 alongside others (custom logging, data structures, html generation utilities) 28 29 # building and usage 30 31 Build with `make`, test with `make test`. 32 33 You can then run it with `./serv` and it'll start a web server serving files 34 under ./public on port 8080 or the next available port. Web requests with a 35 "Profile" header will dump profiling info to logs. 36 37 You can also run the server in a Docker container with `make run`