Ergonomic http lib in zig

crestz:


cestz is more like making server side request its my first real zig projects GitHub - zendrx/crestz · GitHub

Supported Zig versions

zig-0.16.0

2 Likes

Nice job.

I see that you are allocating the response body multiple times. You can save one allocation and one copy by taking taking the buffer from std.Io.Writer.Allocating without re-allocating it, it’s just a slice allocated using the provided allocator. Or just store the entire std.Io.Writer.Allocating inside response, if you want to avoid dealing the internals. GPA allocations in Zig are not exactly fast, so it’s best to avoid them if you can.

Also, it’s really not ideal to create std.http.Client per request. It creates a connection pool, so if you do multiple reqests to the same server, you could likely reuse them.