💾 Archived View for nanako.mooo.com › programming › remigemini.gmi captured on 2024-08-18 at 17:41:23. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2024-02-05)

-=-=-=-=-=-=-

The Scarlet Devil Mansion :: RemiGemini

RemiGemini is an extremely small and lightweight library for interfacing with the Gemini Protocol using the Crystal programming language. It includes classes that aid in the implementation of clients and servers.

Source Code

Examples

Simple Client

require "remigemini"

RemiGemini::Client.get(ARGV[0], noVerify: true) do |resp|
  puts "Response Status: #{resp.status}"
  puts "Response message: #{resp.meta}"
  puts resp.body
end

Simple Server

require "./src/remigemini"

if ARGV.size != 2
  abort("Usage: #{File.basename(PROGRAM_NAME)}  ")
end

server = RemiGemini::Server.new do |request|
  if request.uri.path == "" || request.uri.path == "/"
    resp = RemiGemini::Client::Response.new("Hello, world!")
    resp.to_io(request.sock)
  else
    resp = RemiGemini::Client::Response.new(RemiGemini::StatusCode::NotFound, "Nothing yet :(")
    resp.to_io(request.sock)
  end
end

address = server.bind("localhost", ARGV[0], ARGV[1], port: 8069)
puts "Listening on gemini://#{address}"
server.listen
---------
Page served by Aya https://nanako.mooo.com/fossil/aya/
Aya is under the GNU Affero GPLv3 license