<?php

use Illuminate\Http\Request;
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!
|
*/
$api = app('Dingo\Api\Routing\Router');
$api->version('v1', [
    'namespace' => 'App\Http\Controllers\Api',
    'prefix'    => 'api',
    //'middleware' => ['serializer:array', 'bindings']
], function($api) {
    // 上传不验证
    $api->post('Common/uploadFile', 'CommonController@uploadFile');

    // 限制登录和验证码接口请求频率
    $api->group([
        'middleware' => 'api.throttle',
        'limit'   => config('api.rate_limits.sign.limit'),
        'expires' => config('api.rate_limits.sign.expires'),
    ], function($api) {
        // 短信验证码
        $api->any('passport/login', 'PassportController@login');
    });

    // 需要登录
    $api->group([
        'middleware' => [
            'api.auth'
        ],
    ], function($api) {
        $api->get('user/get', 'UserController@get');
        $api->get('setting/get', 'SettingController@get');
    });

});
