douyan8772 2015-06-12 12:12
浏览 7

处理laravel的路线

I have api with two different versions v1 and v2 both of them have same end points. But the way i handle sessions is different, what will be the clean way of handling routes file and to know which api version user is using. I am using laravel 4.1

Example routes:

/v1/getsome/1
/v2/getsome/1

Thanks in advance

  • 写回答

2条回答 默认 最新

  • dsdfd2322 2015-06-12 12:20
    关注

    v1/v2 can easily be a placeholder,so in the future you could change/increase the versioning without breaking the api

    Route::get('{version}/getSome/{id}', ['as' => 'getstome', 'uses' => 'controller@method');
    

    And then you handle the version in the cotnroller's method.

    Or you could use a prefix (I'd prefer this), so you don't need to specify the version in your routes:

    Route::group(['prefix' => 'v1'], function(){
      Route::get('getsome/{id}', ....);
    };
    
    评论

报告相同问题?

悬赏问题

  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 Revit2020下载问题
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 单片机无法进入HAL_TIM_PWM_PulseFinishedCallback回调函数
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch