XF_Index/routes/api.php

39 lines
1.2 KiB
PHP
Raw Normal View History

2023-06-10 14:21:40 +08:00
<?php
/*
* Copyright © 2016 - 2023 筱锋xiao_lfeng. All Rights Reserved.
* 开发开源遵循 MIT 许可,若需商用请联系开发者
* https://www.x-lf.com/
*/
2023-06-11 14:20:56 +08:00
use App\Http\Controllers\Authme;
2023-06-10 14:21:40 +08:00
use Illuminate\Http\Request;
2023-06-11 14:20:56 +08:00
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Response;
2023-06-10 14:21:40 +08:00
use Illuminate\Support\Facades\Route;
/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
2023-06-11 14:20:56 +08:00
Route::middleware('auth')->get('/user', function (Request $request) {
2023-06-10 14:21:40 +08:00
return $request->user();
});
2023-06-11 14:20:56 +08:00
Route::prefix('api')->group(function () {
Route::prefix('auth')->group(function () {
Route::post('login',[Authme::class,'Login'])->name('api.auth.login');
Route::post('register',[Authme::class,'Register'])->name('api.auth.register');
Route::match(['get','post'],'logout',function () {
Auth::logout();
return Response::redirectTo('');
})->name('logout');
});
});