Class: GdsApi::Router
- Inherits:
-
Base
- Object
- Base
- GdsApi::Router
show all
- Defined in:
- lib/gds_api/router.rb
Instance Attribute Summary
Attributes inherited from Base
#options
Instance Method Summary
collapse
-
#add_backend(id, url) ⇒ Object
-
#add_gone_route(path, type, options = {}) ⇒ Object
-
#add_redirect_route(path, type, destination, redirect_type = "permanent", options = {}) ⇒ Object
-
#add_route(path, type, backend_id, options = {}) ⇒ Object
-
#commit_routes ⇒ Object
-
#delete_backend(id) ⇒ Object
-
#delete_route(path, hard_delete: false, commit: false) ⇒ Object
-
#get_backend(id) ⇒ Object
-
#get_route(path) ⇒ Object
Methods inherited from Base
#client, #create_client, #get_list, #initialize, #url_for_slug
Constructor Details
This class inherits a constructor from GdsApi::Base
Instance Method Details
#add_backend(id, url) ⇒ Object
10
11
12
|
# File 'lib/gds_api/router.rb', line 10
def add_backend(id, url)
put_json("#{endpoint}/backends/#{CGI.escape(id)}", backend: { backend_url: url })
end
|
#add_gone_route(path, type, options = {}) ⇒ Object
47
48
49
50
51
|
# File 'lib/gds_api/router.rb', line 47
def add_gone_route(path, type, options = {})
response = put_json("#{endpoint}/routes", route: { incoming_path: path, route_type: type, handler: "gone" })
commit_routes if options[:commit]
response
end
|
#add_redirect_route(path, type, destination, redirect_type = "permanent", options = {}) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/gds_api/router.rb', line 30
def add_redirect_route(path, type, destination, redirect_type = "permanent", options = {})
response = put_json(
"#{endpoint}/routes",
route: {
incoming_path: path,
route_type: type,
handler: "redirect",
redirect_to: destination,
redirect_type: redirect_type,
segments_mode: options[:segments_mode],
},
)
commit_routes if options[:commit]
response
end
|
#add_route(path, type, backend_id, options = {}) ⇒ Object
24
25
26
27
28
|
# File 'lib/gds_api/router.rb', line 24
def add_route(path, type, backend_id, options = {})
response = put_json("#{endpoint}/routes", route: { incoming_path: path, route_type: type, handler: "backend", backend_id: backend_id })
commit_routes if options[:commit]
response
end
|
#commit_routes ⇒ Object
62
63
64
|
# File 'lib/gds_api/router.rb', line 62
def commit_routes
post_json("#{endpoint}/routes/commit", {})
end
|
#delete_backend(id) ⇒ Object
14
15
16
|
# File 'lib/gds_api/router.rb', line 14
def delete_backend(id)
delete_json("#{endpoint}/backends/#{CGI.escape(id)}")
end
|
#delete_route(path, hard_delete: false, commit: false) ⇒ Object
53
54
55
56
57
58
59
60
|
# File 'lib/gds_api/router.rb', line 53
def delete_route(path, hard_delete: false, commit: false)
url = "#{endpoint}/routes?incoming_path=#{CGI.escape(path)}"
url += "&hard_delete=true" if hard_delete
response = delete_json(url)
commit_routes if commit
response
end
|
#get_backend(id) ⇒ Object
6
7
8
|
# File 'lib/gds_api/router.rb', line 6
def get_backend(id)
get_json("#{endpoint}/backends/#{CGI.escape(id)}")
end
|
#get_route(path) ⇒ Object
20
21
22
|
# File 'lib/gds_api/router.rb', line 20
def get_route(path)
get_json("#{endpoint}/routes?incoming_path=#{CGI.escape(path)}")
end
|