Bind go-ruby-rack and go-ruby-sinatra into rbgo as native modules#104
Merged
Conversation
Wire the go-ruby-rack and go-ruby-sinatra libraries into the embedded Ruby
runtime, closing the two web-app gaps the run-conformance harness surfaced:
`require "rack"` and the Sinatra DSL (`require "sinatra/base"`).
rack (require "rack" / "rack/utils"):
- Rack::RELEASE, Rack::Request (env accessors + parsed params), Rack::Response
(buffered status/headers/body + #finish/#to_a triple), Rack::Utils
(escape/unescape/escape_html/parse_query/build_query/status_code).
- Deterministic env/query/escape over the library; no socket, no network.
sinatra (require "sinatra/base" / "sinatra"):
- Sinatra::Base with the class-level routing DSL (get/post/put/delete/patch/
options/head), before/after filters, not_found / error handlers,
set/enable/disable/configure/helpers, and the Rack #call adapter
(App.new.call(env) -> [status, headers, body]) available as both an instance
and a class method.
- Route/filter blocks run against a SinatraCtx exposing params, request,
response, status, body, headers, content_type, redirect, halt, pass, session
and settings; halt/redirect/pass unwind through the library's panic-based
control flow, which the dispatcher recovers. The handler-block eval is the
rbgo seam; routing, param extraction and dispatch are the go-ruby-sinatra
library over go-ruby-rack.
- Subclasses inherit their ancestors' routes; per-class declarations are keyed
by the class object.
The webapp run-conformance stage 3 (Sinatra DSL) now RUNS green:
GET /hi?n=amy -> [200, headers, ["hi amy"]].
Registered after registerRack (Sinatra reuses Rack::Request/Response and needs
StandardError for Sinatra::NotFound). New binding code is at 100% coverage under
the -race -coverpkg CI gate (TZ=UTC); gofmt/vet clean.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Wire go-ruby-rack and go-ruby-sinatra into the embedded Ruby runtime, closing the two web-app gaps the run-conformance harness surfaced:
require "rack"and the Sinatra DSL (require "sinatra/base"). Both libraries were CI-green but never bound.rack (
require "rack"/"rack/utils")Rack::RELEASE,Rack::Request(env accessors + parsedparams/GET/POST/cookies),Rack::Response(buffered status/headers/body,#finish/#to_a→[status, headers, body]),Rack::Utils(escape/unescape/escape_html/parse_query/build_query/status_code).sinatra (
require "sinatra/base"/"sinatra")Sinatra::Basewith the class-level routing DSL (get/post/put/delete/patch/options/head),before/afterfilters,not_found/errorhandlers,set/enable/disable/configure/helpers, and the Rack#calladapter —App.new.call(env)→[status, headers, body](also a class method).params,request,response,status,body,headers,content_type,redirect,halt,pass,session,settings.halt/redirect/passunwind through the library's panic-based control flow, which the dispatcher recovers. The handler-block eval is the rbgo seam; routing, param extraction and dispatch are the go-ruby-sinatra library over go-ruby-rack.Conformance
The webapp run-conformance stage 3 (Sinatra DSL) now RUNS green (hard assertion):
GET /hi?n=amy→[200, headers, ["hi amy"]].Gates
go test ./...green underTZ=UTC.-race -coverpkg=$(go list ./internal/... | paste -sd,)).🤖 Generated with Claude Code