#safe #http #pure #dynamic

nightly bin+lib mudpie

Dynamic HTTP Server. Pure safe Rust, no dependencies.

21 releases

Uses old Rust 2015

0.2.6 Jun 13, 2015
0.2.5 Apr 3, 2015
0.2.3 Mar 27, 2015
0.2.2 Feb 22, 2015
0.0.9 Jan 24, 2015

#251 in #pure

Download history 6/week @ 2024-06-27 134/week @ 2024-07-04 35/week @ 2024-09-19 16/week @ 2024-09-26

51 downloads per month

Unlicense

1MB
1K SLoC

Contains (ELF exe/lib, 1.5MB) a, (ELF exe/lib, 785KB) b, (ELF exe/lib, 650KB) x

Mudpie

:app: Mudpie

Overview

{app} is a simple multi-threaded HTTP server for the amazingly awesome Rust language. It is inspired by Python's WSGI specification.

{app} 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 {app} master branch is for Rust nightly.

Hello World Code

[source,rust]

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.

No runtime deps