我正在使用Rails 5構建API,並嘗試使用curl或httpie在命令行上本地測試本地請求。如何在Rails 5本地使用curl或httpie訪問子域名
但是,我在我的路線中使用了constraints subdomain: 'api'
,並且curl和httpie都不喜歡這樣。如果我打開Chrome並轉至http://api.localhost:3000/v1/users
,我會收到有效回覆。然而,隨着httpie我得到這個錯誤:
http: error: ConnectionError: HTTPConnectionPool(host='api.localhost', port=3000):
Max retries exceeded with url: /v1/users (Caused by NewConnectionError('<requests.packages.urllib3.connection.HTTPConnection
object at 0x105732550>: Failed to establish a new connection: [Errno 8]
nodename nor servname provided, or not known',)) while doing GET request to
URL: http://api.localhost:3000/v1/users
我幾乎certin這是由於子域,但我找不到任何地方的任何文件是指使用與捲曲或httpie子域。我怎樣才能做到這一點?