asvae / laravel-api-tester

Test your routes without hassle
http://laravel-api-tester.asva.by/
MIT License
354 stars 52 forks source link

options 颜色列表不存在导致的 bug #43

Open yunlongw opened 5 years ago

yunlongw commented 5 years ago

我在路由中定义了一个 options 的路由 ,在打开 api-test 模块后报错 Undefined index: OPTIONS

vendor/laravel-admin-ext/api-tester/src/ApiTester.php

   public static $methodColors = [
        'GET'    => 'green',
        'HEAD'   => 'gray',
        'POST'   => 'blue',
        'PUT'    => 'yellow',
        'DELETE' => 'red',
        'PATCH'  => 'aqua',
    ];

vendor/laravel-admin-ext/api-tester/resources/views/index.blade.php

@foreach($routes as $route)
    @php ($color = Encore\Admin\ApiTester\ApiTester::$methodColors[$route['method']])
        <li class="route-item"
            data-uri="{{ $route['uri'] }}"
            data-method="{{ $route['method'] }}"
            data-method-color="{{$color}}"
            data-parameters='{!! $route['parameters'] !!}' >

            <a href="#"><b>{{ $route['uri'] }}</b>
            <div class="pull-right">
                <span class="label bg-{{ $color }}">{{ $route['method'] }}</span>
            </div>
            </a>
        </li>
@endforeach