我有以下的葡萄根類定義Rails的葡萄揚鞭:獲取當前域BASE_PATH
module Api
class Root < Grape::API
mount Api::Version1
add_swagger_documentation :mount_path => 'docs',
:base_path => "/api",
:markdown => true,
:hide_documentation_path => true
end
end
的問題是「:BASE_PATH」應包括一個完整的URL,我不知道在哪裏得到它。 我檢查了ENV變量,並且沒有任何與當前域接近的東西。也沒有任何類型的「請求」對象。 Ruby中有什麼方法我可以獲取當前域,即HTTP_HOST變量?
好的,謝謝 –