Example #1
0
    def test_redirect_can_use_301(self):
        request = Request(generate_wsgi())
        route = Redirect('/test1', '/test3', status=301)

        route.load_request(request)
        request.load_app(App())
        route.get_response()
        assert request.is_status(301)
        assert request.redirect_url == '/test3'
Example #2
0
    def test_redirect_route(self):
        route = Redirect('/test1', '/test2')
        request = Request(generate_wsgi())
        route.load_request(request)
        request.load_app(App())

        route.get_response()
        assert request.is_status(302)
        assert request.redirect_url == '/test2'
Example #3
0
 def test_redirect_can_change_method_type(self):
     request = Request(generate_wsgi())
     route = Redirect('/test1', '/test3', methods=['POST', 'PUT'])
     assert route.method_type == ['POST', 'PUT']
Example #4
0
 def test_redirect_can_change_method_type(self):
     route = Redirect('/test1', '/test3', methods=['POST', 'PUT'])
     self.assertEqual(route.method_type, ['POST', 'PUT'])
Example #5
0
""" Web Routes """
from masonite.helpers.routes import group
from masonite.routes import Get, Post, Redirect

ROUTES = [
    Get().route('/test', None).middleware('auth'),
    Get().route('/queue', 'TestController@queue'),
    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().route('/json_response', 'TestController@json_response'),
    Post().route('/test/post/route', 'TestController@post_test'),
    Get().route('/login', 'TestController@testing').name('login'),
    Get().route('/test/param/@id', 'TestController@testing'),
    Post().route('/test/json/response/@id', 'TestController@json'),
    Get().route('/test/set/test/session', 'TestController@session'),
    group('/example', [
        Get().route('/test/1', 'TestController@show'),
        Get().route('/test/2', 'TestController@show')
    ])
]
Example #6
0
        Get().route('/', DisplayBlogController.show),
        Get().route('/@a', DisplayBlogController.show),
        Get().route('/@a/@b', DisplayBlogController.show),
        Get().route('/@a/@b/@c', DisplayBlogController.show),
    ],
               prefix='/blog'),
    RouteGroup([
        RouteGroup([
            Get().route('/toppage', DisplayBlogController.get_toppage),
            Get().route('/series', DisplayBlogController.get_series),
            Get().route('/articles/@series_id:int',
                        DisplayBlogController.get_articles),
            Get().route('/article/@timestamp:int',
                        DisplayBlogController.get_article),
            Get().route('/diaries', DisplayBlogController.get_diaries),
            Get().route('/articlesByKeyword',
                        DisplayBlogController.get_articles_by_keyword),
            Get().route('/articlesByTagId/@tag_id:int',
                        DisplayBlogController.get_articles_by_tag_id),
        ],
                   prefix='/blog'),
        RouteGroup([
            Get().route('/download', ResumeController.show),
        ],
                   prefix='/resume'),
    ],
               prefix='/api'),
    Get().route('/masonite', WelcomeController.show),
    Redirect('/', '/blog/'),
]