Created
November 9, 2020 00:46
-
-
Save Marlysson/ed857dcae62c771b67fa20091e7ea793 to your computer and use it in GitHub Desktop.
How add a new Route Compile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SearchController(Controller): | |
def search(self, request: Request): | |
return request.param("term") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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. | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from masonite.provider import ServiceProvider | |
from masonite.routes import Route | |
class RouteCompilerProvider(ServiceProvider): | |
wsgi = False | |
def boot(self, route: Route): | |
route.compile('any', r'(.+)') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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