#http #request #data #zero #http-post

bin+lib clienter

A simple, lightweight, zero dependency, HTTP client for Rust

3 releases

0.1.2 Feb 16, 2025
0.1.1 Feb 7, 2025
0.1.0 Feb 7, 2025

#124 in HTTP client

Download history 234/week @ 2025-02-06 180/week @ 2025-02-13

414 downloads per month
Used in neptune-cash

MIT license

53KB
815 lines

Clienter

Clienter is a project designed to manage client interactions and data efficiently. This README provides an overview of the project, how to set it up, and how to contribute.

Table of Contents

Installation

To install the project, follow these steps:

  1. Clone the repository:
    git clone https://github.com/yourusername/clienter.git
    
  2. Navigate to the project directory:
    cd clienter
    
  3. Build the project:
    cargo build
    

Usage

To run the project, use:

cargo run

To run the tests:

cargo test

Examples

Here are some examples of how to use the clienter library:

Simple GET Request

use clienter::{HttpClient, HttpMethod};

fn main() {
    let client = HttpClient::new();
    let request = client.request(HttpMethod::GET, "http://httpbin.org/anything");
    let mut response = client.send(&request).unwrap();
    println!("Status: {}", response.status);
    let body = response.body_as_string().unwrap();
    println!("Body: {}", body);
}

POST Request with JSON Body

use clienter::{HttpClient, HttpMethod, HttpRequest};

fn main() {
    let client = HttpClient::new();
    let mut request = client.request(HttpMethod::POST, "http://httpbin.org/post");
    request.set_body(r#"{"key": "value"}"#);
    let mut response = client.send(&request).unwrap();
    println!("Status: {}", response.status);
    let body = response.body_as_string().unwrap();
    println!("Body: {}", body);
}

License

This project is licensed under the MIT License. See the LICENSE file for details.

No runtime deps