Created
February 8, 2018 15:42
-
-
Save evaporei/903b4c933e734793712515f80765f577 to your computer and use it in GitHub Desktop.
Rust request to pagar.me API
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
use std::io::prelude::*; | |
use std::net::TcpStream; | |
fn main() { | |
let mut stream = TcpStream::connect("api.pagar.me:80").unwrap(); | |
let mut x = [0; 128]; | |
let req = String::from("GET /1/status\n\n"); | |
let req_bytes = req.into_bytes(); | |
let w = stream.write(&req_bytes); | |
let r = stream.read(&mut x); | |
println!("w{:?}", w); | |
println!("r{:?}", r); | |
println!("{:?}", String::from_utf8_lossy(&x)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Se quiser compilar é só rodar
rustc main.rs
E para instalar Rust:
curl https://sh.rustup.rs -sSf | sh
-> https://doc.rust-lang.org/book/second-edition/ch01-01-installation.html