项目文件夹

文件
wehub-resource-sync 9f2e1cd2af
Ruby / Ruby 4.0.5 (push) Failing after 5m13s
Ruby / Ruby 3.3.4 (push) Failing after 5m43s
Ruby / Ruby 2.6.8 (push) Failing after 16m2s
chore: import upstream snapshot with attribution
2026-07-13 12:33:07 +08:00

33 行
631 B
Ruby

# frozen_string_literal: true
module SampleProject
class ApiHandler
def initialize(store)
@store = store
end
def handle_request(path, params)
case path
when "/users"
list_users(params)
when "/orders"
list_orders(params)
else
{ error: "Not found", status: 404 }
end
end
private
def list_users(params)
users = @store.query("SELECT * FROM users LIMIT #{params[:limit] || 10}")
{ data: users, status: 200 }
end
def list_orders(params)
orders = @store.all(:orders)
{ data: orders, status: 200 }
end
end
end