Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Feb 11, 2023
1 parent 51d67eb commit df78a06
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions robyn/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

logger = logging.getLogger(__name__)


class Robyn:
"""This is the python wrapper for the Robyn binaries."""

Expand Down Expand Up @@ -167,26 +168,34 @@ def terminating_signal_handler(_sig, _frame):
observer.stop()
observer.join()


def add_view(self, endpoint: str, view, const: bool = False):
"""
[This is base handler for the view decorators]
:param endpoint [str]: [endpoint for the route added]
:param handler [function]: [represents the function passed as a parent handler for single route with different route types]
"""

def get_functions(view):
functions = get_all_nested(view)
output = []
for (name, handler) in functions:
for name, handler in functions:
route_type = name.upper()
if route_type in ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS']:
if route_type in [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS",
]:
output.append((route_type.upper(), handler))
return output

handlers = get_functions(view)
routes = []
for (route_type, handler) in handlers:
for route_type, handler in handlers:
routes.append(self._add_route(route_type, endpoint, handler, const))
return routes

Expand All @@ -196,6 +205,7 @@ def view(self, endpoint: str, const: bool = False):
:param endpoint str: endpoint to server the route
"""

def inner(handler):
return self.add_view(endpoint, handler, const)

Expand Down

0 comments on commit df78a06

Please sign in to comment.