Last active
February 11, 2021 14:47
-
-
Save jeffque/414a2aad25c94f3296363b1e5ef21454 to your computer and use it in GitHub Desktop.
Fazendo GET com cabeçalhos usando o HTTP padrão do Ruby
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "uri" | |
| require "net/http" | |
| uri = URI.parse 'meu_endpoint' | |
| requisicao = NET::HTTP::GET.new uri | |
| requisicao['my_header'] = 'valor' | |
| # na documentação também fala do método .add_field | |
| # requisicao.add_field 'my_header', 'valor' | |
| # parece que o add_field ajuda quando o header é uma espécie de vetor | |
| resultado = NET::HTTP.start uri.hostname, uri.port do |http| | |
| http.request requisicao | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment