February 2018
Intermediate to advanced
456 pages
9h 56m
English
We will now create a new microservice responsible for handling HTTP requests. First of all, let's amend our imports in the service.py file:
from nameko.rpc import rpc, RpcProxy from nameko.web.handlers import http
Beneath the KonnichiwaService we made earlier, insert the following:
class WebServer:
name = 'web_server'
konnichiwa_service = RpcProxy('konnichiwa_service')
@http('GET', '/')
def home(self, request):
return self.konnichiwa_service.konnichiwa()
Notice how the follows a similar pattern to the KonnichiwaService. It has a name attribute and a method decorated in order to expose it as an entrypoint. In this case, it is decorated with the http entrypoint. We specify inside the http decorator that it is a ...
Read now
Unlock full access