A low-key HTTP micro-framework for people who hate web bloat
git clone git://soophie.de/tpee
blob: e3558bae24e83adf9f12d47581bb3d932fb10092 (1332 bytes)[doc][blame][raw]
1
# so/http3
A basic HTTP Framework5
## Installation7
```8
git clone git@soophie.de:/srv/git/so/http9
cd http10
sudo make install11
```13
## Quick Start15
```c16
#define SO_HTTP_IMPL17
#include <so/http.h>19
#define HOST "0.0.0.0"20
#define PORT 8022
HTTP_GET("/", index_page) {23
(void) req;24
http_resp_t resp = http_resp_create(HTTP_STATUS_OK);25
http_resp_header(&resp, "Content-Type", "text/html");26
char *html = "<h1>Hello, World!</h1>";27
http_resp_body(&resp, html, strlen(html));28
return resp;29
}31
int main(void) {32
http_t *http = http_init();33
http_err_t err = http_bind_listen(http, HOST, PORT);34
if (err == HTTP_ERR_OK) {35
printf("server is running on %s:%d\n", HOST, PORT);36
pause();37
http_close(http);38
}39
else {40
printf("failed to start server on %s:%d\n", HOST, PORT);41
}42
printf("server stopped\n");43
http_cleanup(http);44
return 0;45
}46
```48
### Compiling50
```bash51
cc -o main -lssl -lcrypto -lpthread main.c52
```54
## License56
This project is licensed under the **GNU General Public License v3.0 (GPLv3)**.58
**What this means:** You are free to use, study, and modify this framework. However, if you distribute a program that uses this framework (including selling it), you **must** provide the full source code of your program under the same GPLv3 license.60
See the [LICENSE](LICENSE) file for the full legal text.