Skip to content

Commit 12beae3

Browse files
Merge pull request #12 from ebuengamarvin/6-Routing
Routing
2 parents 234c866 + becfb8b commit 12beae3

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

routes/api.php

+22-12
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
<?php
22

3+
use App\Http\Controllers\api\AuthController;
4+
use App\Http\Controllers\api\ChatController;
5+
use App\Http\Controllers\api\ChatNameController;
36
use Illuminate\Http\Request;
47
use Illuminate\Support\Facades\Route;
58

6-
/*
7-
|--------------------------------------------------------------------------
8-
| API Routes
9-
|--------------------------------------------------------------------------
10-
|
11-
| Here is where you can register API routes for your application. These
12-
| routes are loaded by the RouteServiceProvider within a group which
13-
| is assigned the "api" middleware group. Enjoy building your API!
14-
|
15-
*/
9+
Route::group([
10+
'prefix' => 'auth'
11+
], function () {
12+
Route::post('login', [AuthController::class, 'login']);
13+
Route::post('register', [AuthController::class, 'register']);
14+
Route::post('logout', [AuthController::class, 'logout']);
1615

17-
Route::middleware('auth:api')->get('/user', function (Request $request) {
18-
return $request->user();
16+
Route::group([
17+
'middleware' => 'auth:sanctum'
18+
], function () {
19+
Route::get('user', [AuthController::class, 'user']);
20+
Route::post('logout', [AuthController::class, 'logout']);
21+
});
22+
});
23+
24+
Route::group([
25+
'middleware' => 'auth:sanctum'
26+
], function () {
27+
Route::apiResource('chatname', ChatNameController::class);
28+
Route::apiResource('chats', ChatController::class);
1929
});

0 commit comments

Comments
 (0)