|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | +|-------------------------------------------------------------------------- |
| 5 | +| Set up 404 handler |
| 6 | +|-------------------------------------------------------------------------- |
| 7 | +| |
| 8 | +| Create a handler for 404 errors |
| 9 | +| |
| 10 | +*/ |
| 11 | +$app->set404(function () use ($app) { |
| 12 | + $app->response->respondWithCode([ |
| 13 | + "data" => "Resource not found", |
| 14 | + ], 404); |
| 15 | +}); |
| 16 | + |
| 17 | +/* |
| 18 | +|-------------------------------------------------------------------------- |
| 19 | +| Set up Controller namespace |
| 20 | +|-------------------------------------------------------------------------- |
| 21 | +| |
| 22 | +| This allows you to directly use controller names instead of typing |
| 23 | +| the controller namespace first. |
| 24 | +| |
| 25 | +*/ |
| 26 | +$app->setNamespace("\App\Controllers"); |
| 27 | + |
| 28 | +$app->get("/", function() use($app) { |
| 29 | + $app->response->respondWithCode("Welcome to bitcart API v2", 200); |
| 30 | +}); |
| 31 | + |
| 32 | +$app->mount('/info', function() use($app) { |
| 33 | + $app->get('/', 'InfoController@index'); |
| 34 | + $app->get('/addresses', 'InfoController@addresses'); |
| 35 | + $app->get('/qr', 'InfoController@qr'); |
| 36 | + $app->get('/bank', 'InfoController@bank'); |
| 37 | + $app->get('/mobile', 'InfoController@mobile'); |
| 38 | + $app->get('/tax', 'InfoController@tax'); |
| 39 | +}); |
| 40 | + |
| 41 | +$app->mount('/auth', function() use($app) { |
| 42 | + $app->post('/login', 'AuthController@login'); |
| 43 | + $app->post('/register', 'AuthController@register'); |
| 44 | +}); |
| 45 | + |
| 46 | +$app->mount('/account', function() use($app) { |
| 47 | + $app->get('/', 'AccountController@user'); |
| 48 | + $app->get('/verify/{username}', 'AccountController@verifyUsername'); |
| 49 | + $app->post('/update', 'AccountController@update'); |
| 50 | + $app->post('/update/password', 'AccountController@password'); |
| 51 | +}); |
| 52 | + |
| 53 | +$app->mount('/transactions', function() use($app) { |
| 54 | + $app->get('/', 'TransactionsController@index'); |
| 55 | + $app->get('/(\d+)', 'TransactionsController@withLimit'); |
| 56 | +}); |
| 57 | + |
| 58 | +$app->mount('/transaction', function() use($app) { |
| 59 | + $app->get('/(\d+)', 'TransactionsController@transaction'); |
| 60 | +}); |
0 commit comments