Spikard

Bindings Rust Python Node.js WASM Ruby PHP Elixir Java Go C# Kotlin Dart Swift Zig C FFI Homebrew License Documentation
Join Discord

Rust-centric polyglot HTTP framework with OpenAPI/AsyncAPI/GraphQL/JSON-RPC codegen, tower-http middleware, and fixture-driven cross-language testing. Ruby bindings via Magnus with idiomatic Ruby API.

What This Package Provides

  • HTTP application core — typed routing, request data extraction, validation, lifecycle hooks, and Tower middleware from the Rust engine.
  • Spec-driven work — OpenAPI, AsyncAPI, GraphQL SDL, JSON-RPC, and SQL-to-HTTP codegen are shared across bindings.
  • Cross-language parity — generated bindings use the same DTOs, fixtures, and error model, so behavior does not drift between runtimes.
  • Native integration — no sidecar server required; each package calls the Rust core through its language-native bridge.
  • Ruby package — Magnus-backed native extension with Ruby route objects.

Installation

gem:

gem install spikard

Bundler:

gem 'spikard'

System Requirements

  • Ruby 3.2+ required

Quick Start

require "spikard"

app = Spikard::App.new

app.get("/users/:id") do |params, _query, _body|
  { id: params[:id].to_i, name: "Alice" }
end

app.post("/users") do |_params, _query, body|
  user = body
  { id: user["id"], name: user["name"] }
end

app.run(config: { port: 8000 })

Features

  • HTTP routing — type-safe route definitions with path, query, and body parameter validation
  • OpenAPI / AsyncAPI / GraphQL / JSON-RPC — code generation and spec parsing built in
  • Tower middleware — compression, rate limiting, timeouts, auth (JWT/API key), static files
  • Lifecycle hooksonRequest, preValidation, preHandler, onResponse, onError
  • Fixture-driven testing — shared JSON fixtures drive tests across all language bindings
  • Polyglot — single Rust core, thin bindings for Python, Node.js, Ruby, PHP, Elixir, Go, Java, C#, Kotlin, Dart, Gleam, WASM, Swift, Zig, and C FFI

Routing

require "spikard"

app = Spikard::App.new

app.get("/health") { |_params, _query, _body| { status: "ok" } }
app.post("/users") { |_params, _query, body| body }

Validation

require "spikard"

PaymentSchema = Dry::Schema.Params do
  required(:id).filled(:string)
  required(:amount).filled(:float)
end

app = Spikard::App.new

app.post("/payments") do |_params, _query, body|
  PaymentSchema.call(body)
end

Middleware

require "spikard"

app = Spikard::App.new

app.on_request do |request|
  puts "#{request[:method]} #{request[:path]}"
  request
end

Documentation

  • Repository — source code, examples, and contributing guide
  • Examples — working server examples
  • Issues — bug reports and feature requests

Contributing

Contributions are welcome. See CONTRIBUTING.md.

License

MIT License — see LICENSE for details.