falcon icon indicating copy to clipboard operation
falcon copied to clipboard

create unix-socket example

Open ggmichaelgo opened this issue 1 month ago • 1 comments

Create a unix-socket Falcon server example

Types of Changes

  • Maintenance.

Contribution

ggmichaelgo avatar Nov 06 '25 14:11 ggmichaelgo

The client is okay but would it be better to show how to use the endpoint mechanism:

require 'io/endpoint/unix_endpoint'
endpoint = Async::HTTP::Endpoint.parse("http://localhost:9292", endpoint: IO::Endpoint.unix("http.ipc"))
# => #<Async::HTTP::Endpoint http://localhost:9292/ {endpoint: #<IO::Endpoint::UNIXEndpoint path="http.ipc">}>

# Just for the sake of running this in irb:
Async{binding.irb}

server = Async::HTTP::Server.for(endpoint) do |request|
  Protocol::HTTP::Response[200]
end
# => #<Async::HTTP::Server:0x000000012ba770e8
server.run
# => #<Async::Task:0x0000000000042d80 /Users/samuel/.gem/ruby/ruby-3.4.7/gems/async-2.34.0/lib/async/scheduler.rb:220:in 'IO::Event::Selector::KQueue#resume'>

client = Async::HTTP::Client.new(endpoint)
# => #<Async::HTTP::Client authority="localhost:9292">
client.get("/")
# => #<Async::HTTP::Protocol::HTTP1::Response:0x4a170 status=200>

samuel-williams-shopify avatar Nov 12 '25 22:11 samuel-williams-shopify