Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/helloimalemur/httping
Ping but for HTTP
https://github.com/helloimalemur/httping
Last synced: 5 days ago
JSON representation
Ping but for HTTP
- Host: GitHub
- URL: https://github.com/helloimalemur/httping
- Owner: helloimalemur
- License: mit
- Created: 2024-02-16T18:23:37.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-04-04T19:00:02.000Z (8 months ago)
- Last Synced: 2024-10-16T04:10:02.298Z (about 1 month ago)
- Language: Rust
- Size: 60.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# httping
Httping is like 'ping' but for http-requests.
Provide a URL or IP address, plus the HTTP/HTTPS port number.
Returns with a bool indicating success or failure of the ping,
as well as how long it takes to connect send a request and retrieve
the full response (headers + body) which is returned as an integer "rtt".### Usage
```rust
async fn ping_bool() {
let wrapped_result = ping("koonts.net", "", "http", 80).await;
let result = wrapped_result.unwrap();
println!("{:#?}", result);
assert_eq!(result, true);
}async fn ping_bool_ip() {
let wrapped_result = ping("", "96.30.198.61", "http", 80).await;
let result = wrapped_result.unwrap();
println!("{:#?}", result);
assert_eq!(result, true);
}async fn ping_bool_https() {
let wrapped_result = ping("koonts.net", "", "https", 443).await;
let result = wrapped_result.unwrap();
println!("{:#?}", result);
assert_eq!(result, true);
}
async fn ping_bool_ip_https() {
let wrapped_result = ping("", "96.30.198.61", "https", 443).await;
let result = wrapped_result.unwrap();
println!("{:#?}", result);
assert_eq!(result, true);
}async fn ping_full() {
let wrapped_result = ping_with_metrics("koonts.net", "", "http", 80).await;
let result = wrapped_result.unwrap();
let success = result.success;
let rtt = result.rtt;
println!("{:#?}", result);
assert_eq!(success, true);
assert!(rtt > 0)
}
```## Development and Collaboration
#### Feel free to open a pull request, please run the following prior to your submission please!
echo "Run clippy"; cargo clippy -- -D clippy::all
echo "Format source code"; cargo fmt -- --check