Implementation Pure Zig REST API Implementation for Learning

Hi everyone,

I hope you’re all having a great day.

I am currently in the process of transitioning my perspective from Go (Golang) to Zig, and I am deeply impressed by Zig’s philosophy on memory management and explicit control. To help me better understand the language, I am looking for a simple REST API documentation or source code implementation (Read & Create) using pure Zig without any third-party libraries.

I am particularly interested in seeing how the community handles data persistence in a ‘Zig-way’, whether it’s:

  1. In-Memory (storing data directly in RAM using Allocators).

  2. Embedded Database (using SQLite).

  3. External Database (such as PostgreSQL).

My main goal is to study the technical nuances of Zig’s std.http and compare the performance and developer experience with the standard net/http package in Go.

If anyone could share a minimalist snippet, a GitHub repository, or a guide that is compatible with the latest Zig 0.16/17.0-dev, I would be immensely grateful.

Thank you so much for your kindness and for any assistance you can provide!

6 Likes

llllOllOOll/spiderstack

3 Likes

Concrete example (no frameworks, etc.):

2 Likes

This is exactly the pure Zig implementation I’ve been looking for! Thanks a lot, mate. I’m going to dive deep into the code and study it. Once I’m done, I’ll be ‘pitting’ it against my Golang backend to see how they stack up!

Wow, a new framework! It’s impressive to see Spider already compatible with Zig 0.17.0-dev. I’m excited to see how the developer experience feels with this one. Previously, I tried Jetzig and while it’s a solid framework, I found it struggling a bit with compatibility on the latest Zig versions. Can’t wait to take this for a spin!

tokamak is ioc container based on http.zig, very suitable for rest api.

cztomsik/tokamak: Web framework for Zig that leverages dependency injection for clean, modular application development.

sqlite: cztomsik/fridge: A small, batteries-included database library for Zig.

postgresql: karlseguin/pg.zig: Native PostgreSQL driver / client for Zig.