From:

To:


Design the service-level routing API.


In Django, you can call reverse to transform an abstract view name into a materialised URL, but because we operate a services architecture, this URL reversing is not available between services. I am going to create a service_routing utility which provides this ability.

It comprises of two functions:

  1. Service A makes a request to Service B by its Service Name and View Name
  2. Service B routes any requests to api_router to the appropriate view

Make a Request to Another Service

service_request()
	service_name,
	app_name
	view_name,
	path_path_params,
	... # regular requests.request args: headers, body, etc.
)

We restrict service API requests to json content on both request and response meaning we keep things uniform.