Seregon/zftpd

Zero-copy FTP/HTTP Daemon compatible with all POSIX systems

C/11.0 KB/No license
docs/API.md
zftpd / docs / API.md
1# zhttpd REST API Documentation
2 
3## Endpoints
4 
5### GET /api/list
6 
7List directory contents.
8 
9**Query Parameters:**
10- `path` (required): Directory path
11 
12**Response:**
13```json
14{
15 "path": "/home",
16 "entries": [
17 {
18 "name": "file.txt",
19 "type": "file",
20 "size": 1024
21 },
22 {
23 "name": "subdir",
24 "type": "directory",
25 "size": 0
26 }
27 ]
28}
29```
30 
31**Errors:**
32- `404`: Directory not found
33- `500`: Internal error
34 
35### GET /api/download
36 
37Download file (TODO).
38 
39### Static Files
40 
41- `GET /` → `index.html`
42- `GET /style.css` → CSS
43- `GET /app.js` → JavaScript
44 
45## Adding Custom Endpoints
46 
47Edit `zhttpd/src/http_api.c`:
48 
49```c
50http_response_t* http_api_handle(const http_request_t *request) {
51 if (strncmp(request->uri, "/api/custom", 11) == 0) {
52 return handle_custom(request);
53 }
54 // ... existing handlers
55}
56```
57