Sha256: dce71da0d2b9a4caa30d728c6b4837c212730caee0747182967c6958b6acca52

Contents?: true

Size: 744 Bytes

Versions: 1

Compression:

Stored size: 744 Bytes

Contents

require_relative "./lib/rowdy.rb"

module Model
  class Person < Data.define(:name, :email)
    def self.all
      10.times.map { |n| find n }
    end

    def self.find(id)
      new name: "Person #{id}", email: "person-#{id}@example.com"
    end
  end
end

# Application code (dev sees this)
class Application < Rowdy::Server
  def route(http)
    http.response.headers["Content-Type"] = "text/plain"
    http.response.status = 200

    case http.request
      in root: true
        http.response.write "Hello world!"
      in path: ["people", *_ ]
        Rowdy::Controller::Resources.new(scope: Model::Person).route(http)
    else
      http.response.write "Not Found"
      http.response.status = 404
    end
  end
end

run Application.new

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rowdy-0.1.0 config.ru