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'
def put(url, controller): """Shortcut for Put 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.Put -- The Masonite Put class. """ return Put().route(url, controller)
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')
"""Web Routes.""" from masonite.routes import RouteGroup from masonite.routes import Get, Post, Put ROUTES = [ RouteGroup([ # Authentication Post('/users/login', 'AuthController@login'), # User Post('/users', 'UserController@create'), Get('/user', 'UserController@currunt_user'), Put('/user', 'UserController@update'), ], prefix='/api') ]
# Dashboard Get('/', 'DashboardController@index').name('dashboard').middleware('auth'), # Users Get('/users/@user/edit', 'UsersController@edit').name('users.edit').middleware('auth'), Get('/users/create', 'UsersController@create').name('users.create').middleware('auth'), Post('/users', 'UsersController@store').name('users.store').middleware('auth'), Post('/users/@user', "UsersController@update").name('users.update').middleware('auth'), Get('/users', "UsersController@index").name('users').middleware('auth'), Delete('/users/@user', "UsersController@destroy").name('users.destroy').middleware('auth'), # Organizations Get('/organizations', "OrganizationsController@index").name('organizations').middleware('auth'), Get('/organizations/create', "OrganizationsController@create").name('organizations.create').middleware('auth'), Get('/organizations/@organization/edit', "OrganizationsController@edit").name('organizations.edit').middleware('auth'), Put('/organizations/@organization', "OrganizationsController@update").name('organizations.update').middleware('auth'), Delete('/organizations/@organization', "OrganizationsController@destroy").name('organizations.destroy').middleware('auth'), Post('/organizations/', "OrganizationsController@store").name('organizations.store').middleware('auth'), # Contacts Get('/contacts', "ContactsController@index").name('contacts').middleware('auth'), Get('/contacts/create', "ContactsController@create").name('contacts.create').middleware('auth'), Get('/contacts/@contact/edit', "ContactsController@edit").name('contacts.edit').middleware('auth'), Post('/contacts/', "ContactsController@store").name('contacts.store').middleware('auth'), Delete('/contacts/@contact', "ContactsController@destroy").name('contacts.destroy').middleware('auth'), # Reports Get('/reports', "ReportsController@index").name('reports').middleware('auth'), # Errors Get('/500', "ErrorController@show").name('500')
def put(url, controller): """ Shortcut for Put http """ return Put().route(url, controller)
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", ), RouteGroup( [
"""Web Routes.""" from masonite.routes import RouteGroup, Get, Post, Put, Delete ROUTES = [ RouteGroup([ # Authentication Post('/users/login', 'AuthController@login'), # User Post('/users', 'UserController@create'), Get('/user', 'UserController@current_user').middleware('auth'), Put('/user', 'UserController@update').middleware('auth'), # Profiles RouteGroup([ Get('', 'ProfileController@show'), Post('follow', 'ProfileController@follow'), Delete('follow', 'ProfileController@unfollow'), ], middleware=('auth',), prefix='/profiles/@username'), # Articles Get('/articles', 'ArticleController@index'), RouteGroup([ Post('', 'ArticleController@create'), Get('/feed', 'ArticleController@feed'), Put('/@slug', 'ArticleController@update'), Delete('/@slug', 'ArticleController@delete'), Post('/@slug/favorite', 'ArticleController@favorite'), Delete('/@slug/favorite', 'ArticleController@unfavorite'),