diff --git a/lib/route.rb b/lib/route.rb index e69de29..be5bee4 100644 --- a/lib/route.rb +++ b/lib/route.rb @@ -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 \ No newline at end of file diff --git a/testing.rb b/testing_requests.rb similarity index 100% rename from testing.rb rename to testing_requests.rb diff --git a/testing_routes.rb b/testing_routes.rb new file mode 100644 index 0000000..7ca6a4c --- /dev/null +++ b/testing_routes.rb @@ -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) \ No newline at end of file