Example #1
0
    def test_can_add_routes(self):
        router = RouteCapsule(
            Route.get("/home", "WelcomeController"),
            Route.post("/login", "WelcomeController"),
        )

        self.assertEqual(len(router.routes), 2)
    def test_can_add_routes(self):
        routes = Route.group([
            Route.get("/home", "WelcomeController"),
            Route.post("/login", "WelcomeController"),
        ])

        self.assertEqual(len(routes), 2)
    def test_can_make_route_group(self):
        router = Router(
            Route.group(
                Route.get("/group", "WelcomeController@show"),
                Route.post("/login", "WelcomeController@show"),
                prefix="/testing",
            ))

        route = router.find("/testing/group", "GET")
        self.assertTrue(route)
    def test_group_naming(self):
        router = Router(
            Route.group(
                Route.get("/group", "WelcomeController@show").name(".index"),
                Route.post("/login", "WelcomeController@show").name(".index"),
                prefix="/testing",
                name="dashboard",
            ))

        route = router.find_by_name("dashboard.index")
        self.assertTrue(route)
    def test_can_make_route_group_nested(self):
        router = Router(
            Route.group(
                Route.get("/group", "WelcomeController@show"),
                Route.post("/login", "WelcomeController@show"),
                Route.group(
                    Route.get("/api/user", "WelcomeController@show"),
                    Route.group(Route.get("/api/test", None), prefix="/v1"),
                ),
                prefix="/testing",
            ))

        route = router.find("/testing/api/user", "GET")
        self.assertTrue(route)
        route = router.find("/testing/v1/api/test", "GET")
        self.assertTrue(route)
Example #6
0
from src.masonite.routes import Route
from src.masonite.broadcasting import Broadcast
from src.masonite.authentication import Auth

Route.get("/", "WelcomeController@show").name("welcome"),
Route.post("/", "WelcomeController@show"),
Route.post("/upload", "WelcomeController@upload").name("upload"),
Route.get("/test", "WelcomeController@test"),
Route.get("/emit", "WelcomeController@emit"),
Route.get("/view", "WelcomeController@view"),
Route.get("/mail", "MailableController@view"),

Broadcast.routes()
Auth.routes()