关于api路由的新概念,我阅读了很多帖子.我知道api路由用于移动平台,但它们之间存在代码级别差异
在RouteServiceProvider我能看到
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::group([
'middleware' => 'web',
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/web.php');
});
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::group([
'middleware' => 'api',
'namespace' => $this->namespace, …Run Code Online (Sandbox Code Playgroud) 我正在工作的项目的 spring 安全antMatcher实现如下:
http.authorizeRequests()
.antMatchers("/v1/users/**").authenticated()
.antMatchers(HttpMethod.POST, "/v1/users/*/do").permitAll()
Run Code Online (Sandbox Code Playgroud)
当我尝试访问时,/v1/users/2/do我收到一个未经授权的错误,但我希望它可以访问,因为我在 URL 模式中添加了“permitAll()”。
我试过了:
.antMatchers(HttpMethod.POST, "/v1/users/{id}/do").permitAll()
Run Code Online (Sandbox Code Playgroud)
我仍然获得未经授权的访问。