beamtalk-http

March 31, 2026 ยท View on GitHub

HTTP client and server library for Beamtalk.

Built on gun (client) and cowboy (server).

Installation

Add the dependency to your beamtalk.toml:

[dependencies]
http = "0.1.0"

Then run:

beamtalk build

Usage

HTTP Client (one-shot)

resp := (HTTPClient get: "https://httpbin.org/get") unwrap
resp status   // => 200
resp body     // => "..."

resp := (HTTPClient post: "https://httpbin.org/post" body: "{}") unwrap

HTTP Client (persistent actor)

client := HTTPClient spawnWith: #{
  #baseUrl => "https://api.example.com",
  #headers => #(#("Authorization", "Bearer token")),
  #timeout => 10000
}
resp := (client get: "/users") unwrap
client stop

HTTP Server

srv := HTTPServer start: 8080 handler: [:req |
  req method == "GET" ifTrue: [
    HTTPResponse new: #{ #status => 200, #body => "hello" }
  ] ifFalse: [
    HTTPResponse new: #{ #status => 405, #body => "method not allowed" }
  ]
]
srv port   // => 8080
srv stop

HTTP Router

router := HTTPRouter new
router get: "/hello" handler: [:req |
  HTTPResponse new: #{ #status => 200, #body => "hello world" }
]
router post: "/echo" handler: [:req |
  HTTPResponse new: #{ #status => 200, #body => req body }
]

srv := HTTPServer start: 8080 handler: router

Classes

ClassDescription
HTTPClientActor-based HTTP client for one-shot and persistent requests
HTTPServerCowboy-backed HTTP server actor
HTTPRequestIncoming HTTP request representation
HTTPResponseHTTP response builder
HTTPRouterURL routing with method-based dispatch
HTTPRouteIndividual route definition
HTTPRouteBuilderFluent route builder

Development

just build    # Build the package
just test     # Run tests
just fmt      # Check formatting
just ci       # Full CI check (fmt + build + test)

License

Apache-2.0 -- Copyright 2026 James Casey