【问题标题】:Sinatra endpoint is working perfectly on localhost, but not found in production?Sinatra 端点在本地主机上运行良好,但在生产中找不到?
【发布时间】:2017-06-10 13:01:36
【问题描述】:

我有一个无法解决的奇怪问题,我收到了 404 响应正文

<h1>Not Found</h1>

当部署在 heroku 上时,从我的 sinatra API 来看,我有一百条路线,所有路线都可以正常工作,除了这条。这个正在开发中......

namespace '/departments' do

  namespace '/department' do

    get '/single' do
      begin
        dept = API::Department.find(params['department_id'])
        status 200
        body json BODY: {
          department: dept.dept_details
        }
      rescue => error
        puts error
        status 403
        body json DETAIL: error
      end
    end

  end

end

【问题讨论】:

    标签: ruby heroku sinatra


    【解决方案1】:

    已解决:

    显然,在本地主机中,您可以将命名空间相互嵌套,但在生产中它不起作用。

    namespace '/departments' do
    
        get '/department' do
          begin
            dept = API::Department.find(params['department_id'])
            status 200
            body json BODY: {
              department: dept.dept_details
            }
          rescue => error
            puts error
            status 403
            body json DETAIL: error
          end
        end
    
    end
    

    【讨论】:

      猜你喜欢
      • 2013-02-12
      • 2020-02-25
      • 2017-07-22
      • 1970-01-01
      • 2018-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-21
      相关资源
      最近更新 更多