I have an GET Rest endpoint say it as /test/{id}. Currently i am passing id and getting the response as expected. Now i would like that GET endpoint /test/{id} to consume something different value along with id. The different value would be path alias like a/b/c.
so if request is like /test/a/b/c then everything apart from /test i.e. /a/b/c should be treated as single value. How can i achieve that in Falcon.
I tried using router_options converter in falcon.
import falcon
import json
from falcon.routing import BaseConverter
from waitress import serve
class ObjectRequest:
def on_get(self, req, resp):
print(req)
resp.status = falcon.HTTP_200
resp.body = json.dumps({'message': 'Hello World!'})
class AppNameConverter(BaseConverter):
def convert(self, value):
return value
api = falcon.API()
api.router_options.converters.update({
'app_name': AppNameConverter
})
api.add_route('/test/{app:app_name}', ObjectRequest())
serve(app=api, host='127.0.0.1', port=8000)