refactor(http): split HTTP_Send into smaller idiomatic FFI functions#84
Merged
refactor(http): split HTTP_Send into smaller idiomatic FFI functions#84
Conversation
- Add opaque RawResponse type for *http.Response handle - Add HTTP_Do (makes request, returns handle) - Add HTTP_ResponseStatus, HTTP_ResponseHeaders, HTTP_ResponseBody, HTTP_ResponseClose - Remove HTTP_Send (was raw FFI, now replaced) - Update send() in std_lib/http.ard to use new pattern: - Call http_do to get response handle - Extract status, headers, body via accessor functions - Close response handle explicitly - All new FFI functions are idiomatic (auto-generated wrappers) - HTTP_Serve remains as-is (complex callback pattern)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Refactors the HTTP client FFI from one monolithic raw function into six smaller idiomatic functions, following the pattern outlined in
docs/ffi-simplification.md.Changes
Before
HTTP_Sendwas a 70-line raw FFI function that:[]*runtime.ObjectargumentsResponsestructAfter
Six small idiomatic FFI functions:
HTTP_Do(string, string, any, map[string]string, *int) (any, error)HTTP_ResponseStatus(any) intHTTP_ResponseHeader(any, string) *stringHTTP_ResponseHeaders(any) map[string]stringHTTP_ResponseBody(any) (string, error)HTTP_ResponseClose(any)Key Changes
RawResponseopaque type (extern type) to safely pass*http.Responsebetween Go and Ardsend()instd_lib/http.ardto orchestrate response building in Ard:http_do→ getsRawResponse!Strregistry.gen.go)HTTP_Serveremains as-is (complex callback pattern with VM isolation)Benefits
Testing
TestBytecodeHttpSendUsesRequestTimeout, etc.)samples/server.ard)Documentation
Related:
docs/ffi-simplification.md- FFI simplification analysis