Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/darrensemusemu/httpz
A simple Go like http server implementation
https://github.com/darrensemusemu/httpz
http http-server zig
Last synced: 27 days ago
JSON representation
A simple Go like http server implementation
- Host: GitHub
- URL: https://github.com/darrensemusemu/httpz
- Owner: darrensemusemu
- License: mit
- Created: 2023-02-16T20:50:08.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-28T21:45:58.000Z (almost 2 years ago)
- Last Synced: 2024-11-15T09:42:17.022Z (3 months ago)
- Topics: http, http-server, zig
- Language: Zig
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httpz
A simple Go like http server implementation. Note: WIP.
## Example
### Simple Server
```zig
// ....
const addr = try net.Address.parseIp("0.0.0.0", 8080);
var http_server = httpz.Server.init(allocator, addr);
defer http_server.close();const t = struct {
fn handleHome(res: *httpz.Response, _: *httpz.Request) anyerror!void {
res.status = .ok;
try res.setHeader("Content-Type", "text/plain");
try res.body.appendSlice("Hello World");
}
};var mux = httpz.Mux.init(allocator);
try mux.handle("/", t.handleHome);std.log.info("running on port: 8080", .{});
try http_server.listenAndServe(&mux);
```