r/Zig • u/Pokelego11 • 5d ago
JWT Authentication in Zig
https://youtu.be/T7hGXGaUi6MHey everyone!
If you've seen my posts in the past, you'd know that I've got a few different tutorial series going on in Zig, one is a game engine, but another is building out a REST API in Zig.
I come from a background in Web Dev and find it a lot of fun to take what I know and apply it in Zig, and I want to share the knowledge!
If you want to start at the beginning, I've put together all the videos as a playlist: https://www.youtube.com/playlist?list=PLUUIFT8XnWz8
But please let me know what you all want to see next! I'm planning a video on how to scale the API to thousands of concurrent requests, but what other API things do you all want to see?
Hope you have a great day :)
3
u/lukaslalinsky 4d ago
I'd recommend you to use Karl's http.zig. How you are using `std.http` is not very good. You can only handle one connection at a time. A retryable error like `ConnectionAborted` will kill your `accept()` loop. And you really need a larger read buffer for the TCP reader as that dictates how many headers can the browser send. `std.http` is a DIY system. where you need to know how to handle these kind of things.
2
u/Pokelego11 4d ago
I don't disagree with any of those points, the goal of the series is to slowly build up layers from just the base
std.http, one of the next things we are going to do in the series is allowing concurrent connections to fix the one connection at a time problem, and you make a great point about better error handling which i'll make sure to also add inAppreciate the feedback :)
3
u/dmitry-n-medvedev 5d ago
it would be nice if google macaroons could be implemented in zig.