Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How add a new Route Compile
class SearchController(Controller):
def search(self, request: Request):
return request.param("term")
"""Providers Configuration File."""
...
from app.providers.RouteProvider import RouteCompilerProvider
PROVIDERS = [
# Framework Providers
...
# Optional Framework Providers
...
# Third Party Providers
...
# Application Providers
RouteCompilerProvider, # Adding the Router Compile that we create before.
]
from masonite.provider import ServiceProvider
from masonite.routes import Route
class RouteCompilerProvider(ServiceProvider):
wsgi = False
def boot(self, route: Route):
route.compile('any', r'(.+)')
ROUTES = [
Get('/search/@term:any', "SearchController@search")
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment