Skip to content

Instantly share code, notes, and snippets.

@evaporei
Created February 8, 2018 15:42
Show Gist options
  • Save evaporei/903b4c933e734793712515f80765f577 to your computer and use it in GitHub Desktop.
Save evaporei/903b4c933e734793712515f80765f577 to your computer and use it in GitHub Desktop.
Rust request to pagar.me API
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));
}
@evaporei
Copy link
Author

evaporei commented Feb 8, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment