How do I get Sinatra to work with HTTPClient?

前端 未结 1 1582
忘掉有多难
忘掉有多难 2020-12-19 22:39

I\'m trying to create a facade API that receives requests via Sinatra then launches HTTP requests on Github API in the backend.

In my \"hello world\" script I have:<

相关标签:
1条回答
  • 2020-12-19 23:28

    I found the reason. HTTPClient defines a module named HTTP. By default Sinatra looks for Rack handlers with namespace names HTTP and WEBrick, in that order.

    Since the HTTP namespace has been defined Sinatra actually thinks it's a Rack handler. I think this is a bug in Sinatra. It should check if the handler responds to run before using it.

    Anyway the fix is to use Thin, or if you want to use WEBrick then explicitly tell Sinatra to skip the automatic Rack detection by doing:

    set :server, 'webrick'
    

    That will prevent Sinatra from thinking the HTTPClient HTTP module is Rack handler.

    0 讨论(0)
提交回复
热议问题