From 67ae621818d4b26e3b7f91a2b2b19b13ba39acb5 Mon Sep 17 00:00:00 2001 From: Alexis Kondilis Date: Mon, 7 Oct 2019 03:01:42 +0000 Subject: [PATCH] Done. --- app/application.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/application.rb b/app/application.rb index e69de29bb..117f294cd 100644 --- a/app/application.rb +++ b/app/application.rb @@ -0,0 +1,22 @@ +class Application + + def call(env) + resp = Rack::Response.new + req = Rack::Request.new(env) + + if req.path.match(/items/) + item_name = req.path.split("/items/").last + if item = @@items.find{|i| i.name == item_name} + resp.write item.price + else + resp.status = 400 + resp.write "Item not found" + end + else + resp.status = 404 + resp.write "Route not found" + end + + resp.finish + end +end