Changeset View
Changeset View
Standalone View
Standalone View
swh/core/api/asynchronous.py
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | ): | ||||
"backend_factory should only be provided if backend_class is" | "backend_factory should only be provided if backend_class is" | ||||
) | ) | ||||
self.backend_class = backend_class | self.backend_class = backend_class | ||||
if backend_class is not None: | if backend_class is not None: | ||||
backend_factory = backend_factory or backend_class | backend_factory = backend_factory or backend_class | ||||
for (meth_name, meth) in backend_class.__dict__.items(): | for (meth_name, meth) in backend_class.__dict__.items(): | ||||
if hasattr(meth, "_endpoint_path"): | if hasattr(meth, "_endpoint_path"): | ||||
path = meth._endpoint_path | path = meth._endpoint_path | ||||
http_method = meth._method | |||||
path = path if path.startswith("/") else f"/{path}" | path = path if path.startswith("/") else f"/{path}" | ||||
self.router.add_route( | self.router.add_route( | ||||
"POST", path, self._endpoint(meth_name, meth, backend_factory) | http_method, | ||||
path, | |||||
self._endpoint(meth_name, meth, backend_factory), | |||||
) | ) | ||||
def _renderers(self): | def _renderers(self): | ||||
"""Return an ordered list of renderers in order of increasing desirability (!) | """Return an ordered list of renderers in order of increasing desirability (!) | ||||
See mimetype.best_match() docstring | See mimetype.best_match() docstring | ||||
""" | """ | ||||
return OrderedDict( | return OrderedDict( | ||||
Show All 37 Lines |