curl 如何设置request.env Rails

g52tjvyc  于 2022-11-13  发布在  其他
关注(0)|答案(2)|浏览(119)

我想通过curl或者其他的东西(Net::HTTP.get)来请求,我在请求的时候怎么设置request.env['omniauth.auth']呢?request.env一般是什么?
例如,请查看https://github.com/intridea/omniauth#integrating-omniauth-into-your-application

class SessionsController < ApplicationController
  def create
    @user = User.find_or_create_from_auth_hash(auth_hash)
    self.current_user = @user
    redirect_to '/'
  end

  protected

  def auth_hash
    request.env['omniauth.auth']
  end
end

我不知道如何设置request.env ['omniauth.auth']当我进行 curl 时

unhi4e5o

unhi4e5o1#

你真的需要一些东西来管理ENV全局变量。并像ENV ['omniauth_facebook']一样使用它。
使用dotenv宝石,它在生产中也很好。

wr98u20j

wr98u20j2#

HTTP标头应显示在带有HTTP_前缀的request.env中。
对于httpie,这就像下面这样简单:

http scheme://your-url.tld/path/to/endpoint Header:Something

您应该可以使用request.env['HTTP_Header']访问此文件

相关问题