All Projects → lloydmeta → rusqbin

lloydmeta / rusqbin

Licence: MIT license
A server that stashes your requests for later retrieval so you can do end-to-end testing of code that makes HTTP calls. Available as a binary, a Docker image, and a library.

Programming Languages

rust
11053 projects
Makefile
30231 projects
shell
77523 projects

Projects that are alternatives of or similar to rusqbin

Httplive
HTTP Request & Response Service, Mock HTTP
Stars: ✭ 1,094 (+4276%)
Mutual labels:  mock-server, restful
OkSimple
OkSimple :powerful and simple okhttp network library
Stars: ✭ 57 (+128%)
Mutual labels:  restful
main
Mocks Server monorepo
Stars: ✭ 109 (+336%)
Mutual labels:  mock-server
fintech
python fintech docs
Stars: ✭ 20 (-20%)
Mutual labels:  restful
karate
Test Automation Made Simple
Stars: ✭ 6,384 (+25436%)
Mutual labels:  mock-server
heimdall
Painless OAuth 2.0 Server for CodeIgniter 4 🔥
Stars: ✭ 36 (+44%)
Mutual labels:  restful
angular6-httpclient-example
Angular 6 HttpClient: Consume RESTful API Example
Stars: ✭ 38 (+52%)
Mutual labels:  restful
TIDAL
Reverse engineering the TIDAL API. OAuth2 (RFC 8628 & RFC 6749) and (nearly) all endpoints
Stars: ✭ 78 (+212%)
Mutual labels:  restful
mock-json-server
A mock web server using a JSON file with live-reload support.
Stars: ✭ 31 (+24%)
Mutual labels:  mock-server
vcr.js
Mock server with Proxy and Record support inspired by ruby VCR.
Stars: ✭ 41 (+64%)
Mutual labels:  mock-server
SLazeKit
SLazeKit is a framework providing models mapper and CoreData serializer for RESTful resources.
Stars: ✭ 23 (-8%)
Mutual labels:  restful
Relaxation
Relaxation is a REST framework for ColdFusion that helps you build a REST API. And then it get's the heck out of your way.
Stars: ✭ 22 (-12%)
Mutual labels:  restful
restofus
Restofus - a cross-platform (REST) API client.
Stars: ✭ 18 (-28%)
Mutual labels:  restful
kb-proxy
kb-proxy 是一个可本地部署的、提供代理功能、接口测试管理、支持在线Mock、Host环境管理的在线工具平台。
Stars: ✭ 52 (+108%)
Mutual labels:  mock-server
koa-better-router
❤️ Stable and lovely router for `koa`, using `path-match`. Foundation for building powerful, flexible and RESTful APIs easily.
Stars: ✭ 88 (+252%)
Mutual labels:  restful
bdd-for-all
Flexible and easy to use library to enable your behavorial driven development (BDD) teams to easily collaborate while promoting automation, transparency and reporting.
Stars: ✭ 42 (+68%)
Mutual labels:  restful
Spring-Boot-2
Spring Boot 2.x examples
Stars: ✭ 33 (+32%)
Mutual labels:  restful
manta-style
🚀 The futuristic API Mock Server for Frontend
Stars: ✭ 41 (+64%)
Mutual labels:  mock-server
mock-algolia
A mock server for the Algolia search engine allowing integration testing without the need to hit Algolia's actual servers
Stars: ✭ 18 (-28%)
Mutual labels:  mock-server
json-server
Create a dummy REST API from a json file with zero coding in seconds
Stars: ✭ 34 (+36%)
Mutual labels:  mock-server

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:

Usage

Web API

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

$ docker run lloydmeta/rusqbin:latest

Binary

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.

Library

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() {
      Ok(futures::Async::NotReady)
    } else {
      Ok(futures::Async::Ready(()))
    }
  }))
});

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();
  server_storage.create_bin()
};
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());
req.headers_mut().set(XRusqBinId(bin_id.to_owned()));
let future_resp = client.request(req);

// Here we use core.run to block on response, but you should never
// do this in production code.
client_core.run(future_resp);
// 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.

Credit

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].