Skip to content
/ mudpie Public
forked from benaryorg/mudpie

Dynamic HTTP Server. Pure safe Rust, no dependencies.

Notifications You must be signed in to change notification settings

jessiex/mudpie

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Mudpie

Overview

Mudpie is a simple multi-threaded HTTP server for the amazingly awesome Rust language. It is inspired by Python’s WSGI specification.

Mudpie is written in 100% safe Rust code (no unsafe blocks) and has no dependencies. It is intended to be reliable and easy to audit for security, especially for embedded applications.

Note
The Mudpie master branch is for Rust nightly.

Hello World Code

extern crate mudpie;
use mudpie::{WebServer, WebRequest, WebResponse};

fn hello(req: &WebRequest) -> WebResponse {
    let page = "<h1>Hello World!</h1>".to_string();
    return WebResponse::new_html(page);
}

fn main() {
    let mut svr = WebServer::new();
    svr.add_path("get", "/hello", hello);
    svr.run("127.0.0.1", 8000);
}

Running the Demo Server

Use cargo run to start the included demo server, which has some example pages you can visit at http://localhost:8000/.

$ cargo run 0.0.0.0 8000

     Running `target/demo 0.0.0.0 8000`
listening on 0.0.0.0:8000
starting 10 worker threads
starting monitor loop

You can benchmark it using a program like "boom" or any other HTTP tester:

$ ./goprograms/bin/boom -n 100000 -c 10 -cpus 3 http://localhost:8000/bench

Summary:
  Total:    3.2466 secs.
  Slowest:  0.0342 secs.
  Fastest:  0.0001 secs.
  Average:  0.0003 secs.
  Requests/sec: 30801.6515
Note
You should probably turn request logging off (export MUDPIE_LOGGING=0) or redirect it to /dev/null when benchmarking, and also use cargo run --release to enable compiler optimizations.

More Information

License

Public Domain.

About

Dynamic HTTP Server. Pure safe Rust, no dependencies.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%