首页 > 解决方案 > 那么,如何从我的机架应用程序中删除 Rack::ShowExceptions 呢?

问题描述

我基于机架编写了自己的小型 http 应用程序。而这段代码是初始化机架。(这不是 sinatra,不是 rails,不是 hanami 应用程序)。

ENV['RACK_ENV']='deployment'
# some more initializations
# end then
@rack = Rack::Server.new(
    app: Router.new,
    Host: Cfg.http.host,
    Port: Cfg.http.port,
    Logger: Log,
    environment: Cfg.env.to_s
)

但是如果我让我的应用程序崩溃,我会在浏览器中看到来自 Rack::ShowExceptions 的所有废话。

如何完全禁用、删除它,而不需要修补机架源?

标签: rubyrackhttpserver

解决方案


@rack = Rack::Server.new(
    # ...
    environment: :none
)

我睁开眼睛,发现这里的评论https://github.com/rack/rack/blob/1.6.0/lib/rack/server.rb#L157-L162


推荐阅读