#http #webserver #requests #testing #log

bin+lib rusqbin

Rusqbin is a web server that stashes your requests for later retrieval so you can do end-to-end testing of code that makes HTTP calls. It is available as both a binary and a library.

16 releases

Uses old Rust 2015

0.2.3 Sep 1, 2017
0.2.1 Aug 31, 2017
0.2.0 Jun 15, 2017
0.1.12 Apr 24, 2017
0.1.5 Jan 6, 2017

#507 in HTTP server

Download history 6/week @ 2023-11-02 19/week @ 2023-11-09 2/week @ 2023-11-16 18/week @ 2023-11-23 52/week @ 2023-11-30 1/week @ 2023-12-07 16/week @ 2023-12-14 33/week @ 2023-12-21 1/week @ 2023-12-28 17/week @ 2024-01-04 3/week @ 2024-01-11 36/week @ 2024-01-18 17/week @ 2024-01-25 17/week @ 2024-02-01 17/week @ 2024-02-08 167/week @ 2024-02-15

218 downloads per month

MIT license

773 lines

Rusqbin Build Status Crates.io

Rusqbin is a web server that stashes your requests for later retrieval. It is available as a Docker image, a binary, and a library through crates.io.

Rusdocs are published for:



The web server has the following API for dealing with request bins.

  • POST /rusqbins To create a bin and get back bin_id
  • GET /rusqbins To list bin summaries
  • GET /rusqbins/${bin_id} To get bin-specific summary information
  • GET /rusqbins/${bin_id}/requests To get detailed request information for a bin (lists all requests in the bin)
  • DELETE /rusqbins/${bin_id} To delete a bin

In any other case, send requests with a X-Rusqbin-Id header with a bin_id to have your requests logged to a bin for later retrieval.


$ docker run lloydmeta/rusqbin:latest


To use Rusqbin as a binary, simply install it using cargo install rusqbin and then run rusqbin, and follow the simple usage instructions. The port the server runs on can be set by optionally adding a port argument.

Binary usage demo

Logging is handled by env_logger, so you can configure it at runtime using a RUST_LOG environment variable.


To use it as a library, add it to your project as a crate dependency, then from within Rust code:

use rusqbin::storage::*;
use rusqbin::server::*;
use rusqbin::models::*;
use hyper::{Method, Uri};
use hyper::client::Client;
use hyper::client::Request as HyperRequest;
use std::io::Read;
use std::thread;
use std::sync::{Arc, Mutex};
use std::str::FromStr;
use futures::future;

// Start a BinsServer on port 7000 in another thread, utilising
// a simple mutex for shutting it down. A channel could also work.
let server = Arc::new(BinsServer::new(7000, InMemoryBins::new()));
let arc_stay_alive = Arc::new(Mutex::new(true));
let bg_server = server.clone();
let bg_stay_alive = arc_stay_alive.clone();
thread::spawn(move || {
  bg_server.run_until(future::poll_fn(|| {
    if *bg_stay_alive.lock().unwrap() {
    } else {

let mut client_core = tokio_core::reactor::Core::new().unwrap();
let client = Client::new(&client_core.handle());

// Create a bin via programmatically, making sure to scope the
// storage unlocking with braces properly
let bin = {
  let mut server_storage = server.storage.lock().unwrap();
let bin_id = bin.id.value();

// Fire an HTTP request with the proper X-Rusqbin-Id header
let mut req = HyperRequest::new(Method::Post, Uri::from_str("http://localhost:7000/hello/world").unwrap());
let future_resp = client.request(req);

// Here we use core.run to block on response, but you should never
// do this in production code.
// Check to make sure our HTTP request was received and stashed
// in our rusqbin server
  let mut server_storage = server.storage.lock().unwrap();
  let bin_requests: &Bin = server_storage.get_bin(&bin.id).unwrap();
  let req = &bin_requests[0];
  assert_eq!(req.method, "POST".to_owned());
  assert_eq!(req.path, "/hello/world".to_owned());
// Cleanup by shutting down our server using the mutex
*arc_stay_alive.lock().unwrap() = false;

In the example above, we use the out-of-the-box InMemoryBins for storage, but you can pass any given implementation of rusqbin::storage::Bins when creating a BinsServer.


Rusqbin is a simple port of Requestbin written in Rust. Inspired by Requestinator


~333K SLoC