-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace zap with http.zig for simpler code #16
Conversation
build.zig.zon
Outdated
.url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.14-pre.tar.gz", | ||
.hash = "122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3", | ||
.httpz = .{ | ||
.url = "https://github.com/karlseguin/http.zig/archive/refs/heads/master.tar.gz", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a potential issue in case master
contains breaking changes, but they don't have tags so it's a bit annoying to handle.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of link also seems to work and would pin to a specific commit: https://codeload.github.com/karlseguin/http.zig/tar.gz/1a82beb0dfc22e6fc38e9918e323f8fbd3cb78a3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As an extra (and maybe obvious) comment: there's an HTTP server (and client) in the stdlib.
Not saying we should use it, but I think it was a recent addition in v0.11, if we want to even further remove deps.
Note: I see in the httpz
readme that says that impl "is slow". Not sure that's entirely relevant for our expectations -- but also sharing that (apparent) "fact".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I looked into it before settling on httpz. More importantly it's more low-level than this lib, and so we would have to write more boiler-plate code. We should wait for it to mature and expand before we consider it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Left a comment on something that can avoid using master
for the dependency.
build.zig.zon
Outdated
.url = "https://github.com/zigzap/zap/archive/refs/tags/v0.1.14-pre.tar.gz", | ||
.hash = "122067d12bc7abb93f7ce623f61b94cadfdb180cef12da6559d092e6b374202acda3", | ||
.httpz = .{ | ||
.url = "https://github.com/karlseguin/http.zig/archive/refs/heads/master.tar.gz", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This kind of link also seems to work and would pin to a specific commit: https://codeload.github.com/karlseguin/http.zig/tar.gz/1a82beb0dfc22e6fc38e9918e323f8fbd3cb78a3
const engine_api = @import("engine_api/engine_api.zig"); | ||
const json = std.json; | ||
|
||
var allocator: std.mem.Allocator = undefined; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this removal of a global allocator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah yes, that was the other reason to do this :D
@gballet, just in case, consider this PR approved. |
I found out that using http.zig allowed for much simpler code as it handles errors by itself and also has a ton of nice helpers. It also doesn't rely on an external C library, which de-clutters the
build.zig
a tad.This is a preparatory step before l start implementing more engine API method.