Пример #1
0
 def test_route_can_pass_route_values_in_constructor(self):
     route = Get('test/url', 'BreakController@show')
     assert route.route_url == 'test/url'
     route = Post('test/url', 'BreakController@show')
     assert route.route_url == 'test/url'
     route = Put('test/url', 'BreakController@show')
     assert route.route_url == 'test/url'
     route = Patch('test/url', 'BreakController@show')
     assert route.route_url == 'test/url'
     route = Delete('test/url', 'BreakController@show')
     assert route.route_url == 'test/url'
Пример #2
0
def patch(url, controller):
    """Shortcut for Patch HTTP class.
    
    Arguments:
        url {string} -- The url you want to use for the route
        controller {string|object} -- This can be a string controller or a normal object controller
    
    Returns:
        masonite.routes.Patch -- The Masonite Patch class.
    """

    return Patch().route(url, controller)
Пример #3
0
 def test_route_can_pass_route_values_in_constructor(self):
     route = Get('test/url', 'BreakController@show')
     self.assertEqual(route.route_url, '/test/url')
     route = Head('test/url', 'BreakController@show')
     self.assertEqual(route.route_url, '/test/url')
     route = Post('test/url', 'BreakController@show')
     self.assertEqual(route.route_url, '/test/url')
     route = Put('test/url', 'BreakController@show')
     self.assertEqual(route.route_url, '/test/url')
     route = Patch('test/url', 'BreakController@show')
     self.assertEqual(route.route_url, '/test/url')
     route = Delete('test/url', 'BreakController@show')
     self.assertEqual(route.route_url, '/test/url')
     route = Connect('test/url', 'BreakController@show')
     self.assertEqual(route.route_url, '/test/url')
     route = Options('test/url', 'BreakController@show')
     self.assertEqual(route.route_url, '/test/url')
     route = Trace('test/url', 'BreakController@show')
     self.assertEqual(route.route_url, '/test/url')
Пример #4
0
def patch(url, controller):
    """
    Shortcut for PATCH http
    """
    return Patch().route(url, controller)
Пример #5
0
"""Web Routes."""

from masonite.routes import Get, Post, Patch, Put, RouteGroup

ROUTES = [
    Get("/", "WelcomeController@show").name("welcome"),
    RouteGroup(
        [
            Post("/auth/sign_in", "AuthController@sign_in"),
            RouteGroup(
                [
                    Get("/@user", "AccountController@user_by_id"),
                    Get("/gov_id/@user", "AccountController@user_by_gov_id"),
                    Post("/", "AccountController@register"),
                    Patch("/gov_id/@user",
                          "AccountController@grant_edit_permissions"),
                    Put("/gov_id/@user",
                        "AccountController@revoke_edit_permissions"),
                ],
                prefix="/accounts",
                middleware=("auth", ),
            ),
            RouteGroup(
                [
                    Patch("/@patient_id", "PatientRecordsController@store"),
                    Get("/@patient_id", "PatientRecordsController@show"),
                    Get("/", "PatientRecordsController@index"),
                ],
                middleware=("auth", ),
                prefix="/records",
            ),
Пример #6
0
    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('/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'),
        Patch('/test/patch', 'UnitTestController@patch'),
    ],
               prefix="/unit")
]
Пример #7
0
from masonite.routes import Get, Post, Delete, Patch, RouteGroup

ROUTES = [
    RouteGroup(
        [
            Get().route("", "TodosController@index"),
            Post().route("", "TodosController@create"),
            Delete().route("", "TodosController@deleteAll"),
        ],
        name="todos.",
        prefix="/",
        add_methods=["OPTIONS"],
    ),
    RouteGroup(
        [
            Get().route("@id", "TodosController@show"),
            Patch().route("@id", "TodosController@update"),
            Delete().route("@id", "TodosController@delete"),
        ],
        name="todo.",
        prefix="/",
        add_methods=["OPTIONS"],
    ),
]