How to use the masonite.routes.Get function in masonite

To help you get started, we’ve selected a few masonite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MasoniteFramework / masonite / tests / core / test_request_routes.py View on Github external
def test_method_type_has_required_subdomain(self):
        get = Get().domain('test')
        post = Get().domain('test')

        self.request.environ['HTTP_HOST'] = 'test.localhost:8000'

        get.request = post.request = self.request

        self.assertEqual(get.has_required_domain(), True)
        self.assertEqual(post.has_required_domain(), True)
github MasoniteFramework / masonite / tests / core / test_requests.py View on Github external
def test_request_redirection(self):
        app = App()
        app.bind('Request', self.request)
        app.bind('WebRoutes', [
            Get('/test/url', 'TestController@show').name('test.url'),
            Get('/test/url/@id', 'TestController@testing').name('test.id'),
            Get('/test/url/object', TestController.show).name('test.object')
        ])
        request = app.make('Request').load_app(app)

        self.assertEqual(request.redirect('/test/url/@id', {'id': 1}).redirect_url, '/test/url/1')
        request.redirect_url = None
        self.assertEqual(request.redirect(name='test.url').redirect_url, '/test/url')
        request.redirect_url = None
        self.assertEqual(request.redirect(name='test.id', params={'id': 1}).redirect_url, '/test/url/1')
        request.redirect_url = None
        self.assertEqual(request.redirect(controller='TestController@show').redirect_url, '/test/url')
        request.redirect_url = None
        self.assertEqual(request.redirect(controller=TestController.show).redirect_url, '/test/url/object')
        request.redirect_url = None
        self.assertEqual(request.redirect('some/url').redirect_url, '/some/url')
github MasoniteFramework / masonite / tests / core / test_service_provider.py View on Github external
class ServiceProviderTest(ServiceProvider):

    def register(self):
        self.app.bind('Request', object)


class Mock1Command:
    pass


class Mock2Command:
    pass


ROUTE1 = Get().route('/url/here', None)
ROUTE2 = Get().route('/test/url', None)


class LoadProvider(ServiceProvider):

    def boot(self):
        self.routes([
            ROUTE1,
            ROUTE2
        ])

        self.http_middleware([
            object,
            object
        ])
github MasoniteFramework / masonite / tests / providers / test_route_provider.py View on Github external
def test_route_runs_str_middleware(self):
        self.routes(only=[Get('/view', ControllerTest.returns_a_dict).middleware('test')])
        self.assertEqual(self.get('/view').container.make('Request').path, 'test/middleware/before/ran')
github MasoniteFramework / masonite / tests / providers / test_route_provider.py View on Github external
def test_url_with_dashes_finds_route(self):

        self.routes(only=[Get('/test/@endpoint', ControllerTest.test)])
        self.assertTrue(self.get('/test/user-endpoint').parameterIs('endpoint', 'user-endpoint'))
github MasoniteFramework / masonite / routes / web.py View on Github external
ROUTES = [
    Get().route('/test', None).middleware('auth'),
    Get('/bad', 'TestController@bad'),
    Get('/keyerror', 'TestController@keyerror'),
    Get().route('/queue', 'TestController@queue'),
    Options('options', 'TestController@show'),
    Redirect('/redirect', 'test'),
    Get().domain('test').route('/test', None).middleware('auth'),
    Get().domain('test').route('/unit/test', 'TestController@testing').middleware('auth'),
    Get().domain('test').route('/test/route', 'TestController@testing'),
    Get('/json_response', 'TestController@json_response'),
    Post('/test/post/route', 'TestController@post_test'),
    Get('/login', 'TestController@testing').name('login'),
    Get('/v', 'TestController@v').name('v'),
    Get('/', 'TestController@v').name('v'),
    Get('/test/param/@id', 'TestController@testing'),
    Post('/test/json/response/@id', 'TestController@json'),
    Get('/test/set/test/session', 'TestController@session'),
    RouteGroup([
        Get('/test/1', 'TestController@show'),
        Get('/test/2', 'TestController@show')
    ], prefix='/example'),
    RouteGroup([
        Get('/test/get', 'UnitTestController@show'),
        Get('/test/param/@post_id', 'UnitTestController@param'),
        Post('/test/post', 'UnitTestController@store').middleware('test'),
        Get('/test/get/params', 'UnitTestController@get_params').name('get.params'),
        Post('/test/params', 'UnitTestController@params'),
        Post('/test/user', 'UnitTestController@user'),
        Post('/test/json', 'UnitTestController@json'),
        Get('/test/json/response', 'UnitTestController@response'),
github MasoniteFramework / masonite / routes / web.py View on Github external
ROUTES = [
    Get().route('/test', None).middleware('auth'),
    Get('/bad', 'TestController@bad'),
    Get('/keyerror', 'TestController@keyerror'),
    Get().route('/queue', 'TestController@queue'),
    Options('options', 'TestController@show'),
    Redirect('/redirect', 'test'),
    Get().domain('test').route('/test', None).middleware('auth'),
    Get().domain('test').route('/unit/test', 'TestController@testing').middleware('auth'),
    Get().domain('test').route('/test/route', 'TestController@testing'),
    Get('/json_response', 'TestController@json_response'),
    Post('/test/post/route', 'TestController@post_test'),
    Get('/login', 'TestController@testing').name('login'),
    Get('/v', 'TestController@v').name('v'),
    Get('/', 'TestController@v').name('v'),
    Get('/test/param/@id', 'TestController@testing'),
    Post('/test/json/response/@id', 'TestController@json'),
    Get('/test/set/test/session', 'TestController@session'),
    RouteGroup([
        Get('/test/1', 'TestController@show'),
        Get('/test/2', 'TestController@show')
    ], prefix='/example'),
    RouteGroup([
        Get('/test/get', 'UnitTestController@show'),
        Get('/test/param/@post_id', 'UnitTestController@param'),
        Post('/test/post', 'UnitTestController@store').middleware('test'),
        Get('/test/get/params', 'UnitTestController@get_params').name('get.params'),
        Post('/test/params', 'UnitTestController@params'),
        Post('/test/user', 'UnitTestController@user'),
        Post('/test/json', 'UnitTestController@json'),
        Get('/test/json/response', 'UnitTestController@response'),
        Post('/test/json/validate', 'UnitTestController@validate'),
github MasoniteFramework / masonite / routes / web.py View on Github external
Get('/bad', 'TestController@bad'),
    Get('/keyerror', 'TestController@keyerror'),
    Get().route('/queue', 'TestController@queue'),
    Options('options', 'TestController@show'),
    Redirect('/redirect', 'test'),
    Get().domain('test').route('/test', None).middleware('auth'),
    Get().domain('test').route('/unit/test', 'TestController@testing').middleware('auth'),
    Get().domain('test').route('/test/route', 'TestController@testing'),
    Get('/json_response', 'TestController@json_response'),
    Post('/test/post/route', 'TestController@post_test'),
    Get('/login', 'TestController@testing').name('login'),
    Get('/v', 'TestController@v').name('v'),
    Get('/', 'TestController@v').name('v'),
    Get('/test/param/@id', 'TestController@testing'),
    Post('/test/json/response/@id', 'TestController@json'),
    Get('/test/set/test/session', 'TestController@session'),
    RouteGroup([
        Get('/test/1', 'TestController@show'),
        Get('/test/2', 'TestController@show')
    ], prefix='/example'),
    RouteGroup([
        Get('/test/get', 'UnitTestController@show'),
        Get('/test/param/@post_id', 'UnitTestController@param'),
        Post('/test/post', 'UnitTestController@store').middleware('test'),
        Get('/test/get/params', 'UnitTestController@get_params').name('get.params'),
        Post('/test/params', 'UnitTestController@params'),
        Post('/test/user', 'UnitTestController@user'),
        Post('/test/json', 'UnitTestController@json'),
        Get('/test/json/response', 'UnitTestController@response'),
        Post('/test/json/validate', 'UnitTestController@validate'),
        Get('/test/json/multi', 'UnitTestController@multi'),
        Get('/test/json/multi_count', 'UnitTestController@multi_count'),
github the-benchmarker / web-frameworks / python / masonite / routes / web.py View on Github external
from masonite.routes import Get, Post

ROUTES = [
    Get("/", "PageController@index"),
    Get("/user/@id:int", "PageController@show_user"),
    Post("/user", "PageController@create_user"),
]