Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/zon-dev/zinc

Zinc is a high performance framework written in pure Zig. Zinc focuses on hight-performance, usability, security, and extensibility.
https://github.com/zon-dev/zinc

api framework performance resetful rest-api usability web web-development web-framework zig zig-package zig-zinc ziglang zinc

Last synced: about 1 month ago
JSON representation

Zinc is a high performance framework written in pure Zig. Zinc focuses on hight-performance, usability, security, and extensibility.

Awesome Lists containing this project

README

        

# zinc

----

Zinc is a high-performance web framework written in Zig(Ziglang).

### Usage.

```zig
const zinc = @import("zinc");

pub fn main() !void {
var z = try zinc.init(.{ .port = 8080 });

var router = z.getRouter();
try router.get("/", helloWorld);
try router.add(&.{ .GET, .POST }, "/ping", pong);

var catchers = z.getCatchers();
try catchers.setNotFound(notFound);

try z.run();
}

fn pong(ctx: *zinc.Context, _: *zinc.Request, _: *zinc.Response) anyerror!void {
try ctx.Text(.{}, "pong!");
}

fn helloWorld(ctx: *zinc.Context, _: *zinc.Request, _: *zinc.Response) anyerror!void {
try ctx.JSON(.{}, .{ .message = "Hello, World!" });
}

// Default 404 (not found) page
fn notFound(ctx: *zinc.Context, _: *zinc.Request, _: *zinc.Response) anyerror!void {
try ctx.HTML(.{
.status = .not_found,
}, "

404 Not Found

");
}

```