Class: PublishingPlatformApi::Router

Inherits:
Base
  • Object
show all
Defined in:
lib/publishing_platform_api/router.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#client, #create_client, #get_list, #initialize, #url_for_slug

Constructor Details

This class inherits a constructor from PublishingPlatformApi::Base

Instance Method Details

#add_gone_route(path, type) ⇒ Object



36
37
38
39
40
41
# File 'lib/publishing_platform_api/router.rb', line 36

def add_gone_route(path, type)
  put_json(
    "#{endpoint}/routes",
    route: { incoming_path: path, route_type: type, handler: "gone" },
  )
end

#add_redirect_route(path, type, destination, redirect_type = "permanent", options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/publishing_platform_api/router.rb', line 22

def add_redirect_route(path, type, destination, redirect_type = "permanent", options = {})
  put_json(
    "#{endpoint}/routes",
    route: {
      incoming_path: path,
      route_type: type,
      handler: "redirect",
      redirect_to: destination,
      redirect_type:,
      segments_mode: options[:segments_mode],
    },
  )
end

#add_route(path, type, backend_id) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/publishing_platform_api/router.rb', line 10

def add_route(path, type, backend_id)
  put_json(
    "#{endpoint}/routes",
    route: {
      incoming_path: path,
      route_type: type,
      handler: "backend",
      backend_id:,
    },
  )
end

#delete_route(path, hard_delete: false) ⇒ Object



43
44
45
46
47
48
# File 'lib/publishing_platform_api/router.rb', line 43

def delete_route(path, hard_delete: false)
  url = "#{endpoint}/routes?incoming_path=#{CGI.escape(path)}"
  url += "&hard_delete=true" if hard_delete

  delete_json(url)
end

#get_route(path) ⇒ Object

Routes



6
7
8
# File 'lib/publishing_platform_api/router.rb', line 6

def get_route(path)
  get_json("#{endpoint}/routes?incoming_path=#{CGI.escape(path)}")
end