Added Route file and class

This commit is contained in:
Hannah-Dagemark 2023-12-04 10:19:08 +01:00
commit 12653f6f48
3 changed files with 31 additions and 0 deletions

View file

@ -0,0 +1,21 @@
class Route
attr_reader :routes
def initialize()
@routes = {}
end
def add_route(input)
@routes.merge!(input)
p "added successfully, @routes are: #{@routes}"
end
def match_route(input)
resource = input.resource
if @routes[resource]
return @routes[resource]
else
p "failed to find: #{resource} route"
end
end
end

10
testing_routes.rb Normal file
View file

@ -0,0 +1,10 @@
require_relative 'lib/route'
require_relative 'lib/request'
request_string = File.read('spec/example_requests/get-examples.request.txt')
route = Route.new
request = Request.new(request_string)
examples = {"/nopers" => "okidoki"}
route.add_route(examples)
p route.match_route(request)