xoxo419
V2EX  ›  问与答

Dingo+Laravel-modules 时调用的接口版本无法指定版本 接口?

  •  
  •   xoxo419 · Jul 18, 2018 · 1003 views
    This topic created in 2856 days ago, the information mentioned may be changed or developed.

    文件位置: Modules\TestApi\routes.php

    <?php
    
    $api = app('Dingo\Api\Routing\Router');
    
    $api->version('v1', function ($api) {
        $api->group(['middleware' => 'api', 'prefix' => 'testapi', 'namespace' => 'Modules\TestApi\Http\V1\Controllers'], function($api)
        {
            $api->get('/version', function(){
                return 'this is Modules routes version 1';
            });
        });
    
    });
    
    $api->version('v2', function ($api) {
        $api->group(['middleware' => 'api', 'prefix' => 'testapi', 'namespace' => 'Modules\TestApi\Http\V2\Controllers'], function($api)
        {
            $api->get('/version', function(){
                return 'this is Modules routes version 2';
            });
        });
    
    });
    

    调用接口时报错误:

    {
    "message": "",
    "exception": "Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException",
    "file": "/home/www-data/my_v2_laravel/vendor/laravel/framework/src/Illuminate/Routing/RouteCollection.php",
    "line": 179,
    ....
    ...
    ....
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5997 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 40ms · UTC 02:21 · PVG 10:21 · LAX 19:21 · JFK 22:21
    ♥ Do have faith in what you're doing.