-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroute.rb
36 lines (31 loc) · 813 Bytes
/
route.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'uri'
require 'rack'
class Route
ROUTES = {
"GET" => {
"/" => :survey,
"/survey_report" => :survey_report,
"/thank_you" => :thank_you,
"/already_submitted" => :already_submitted,
"/form_errors" => :form_errors,
"/confirmation" => :confirmation,
"/success" => :success,
"/failure" => :failure,
},
"POST" => {
"/thank_you" => :thank_you,
"/already_submitted" => :already_submitted,
"/form" => :form,
}
}
attr_accessor :name
def initialize(env)
@request = Rack::Request.new(env)
http_method = @request.request_method
path = @request.path
@name = ROUTES[http_method] && ROUTES[http_method][path]
end
def name
@name || "404"
end
end