"Rust is a systems programming language that runs blazingly fast, prevents almost all crashes*, and eliminates data races."
* In theory. Rust is a work-in-progress and may do anything it likes up to and including eating your laundry.
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.put("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.post("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.delete("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/bar", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/a/*/d", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/a/**/d", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
server.utilize(Nickel::static_files("examples/assets/"));
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/a/**/d", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
fn main() {
let mut server = Nickel::new();
server.utilize(Nickel::static_files("examples/assets/"));
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/a/**/d", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate serialize;
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
#[deriving(Decodable, Encodable)]
struct Person {
firstname: String,
lastname: String,
}
fn main() {
let mut server = Nickel::new();
server.utilize(Nickel::json_body_parser());
fn post_handler (request: &Request, response: &mut Response) {
let person = request.json_as::<Person>().unwrap();
let text = format!("Hello {} {}", person.firstname, person.lastname);
response.send(text.as_slice());
}
server.post("/a/post/request", post_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate serialize;
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
#[deriving(Decodable, Encodable)]
struct Person {
firstname: String,
lastname: String,
}
fn main() {
let mut server = Nickel::new();
server.utilize(Nickel::json_body_parser());
fn post_handler (request: &Request, response: &mut Response) {
let person = request.json_as::<Person>().unwrap();
let text = format!("Hello {} {}", person.firstname, person.lastname);
response.send(text.as_slice());
}
server.post("/a/post/request", post_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate serialize;
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
#[deriving(Decodable, Encodable)]
struct Person {
firstname: String,
lastname: String,
}
fn main() {
let mut server = Nickel::new();
server.utilize(Nickel::json_body_parser());
fn post_handler (request: &Request, response: &mut Response) {
let person = request.json_as::<Person>().unwrap();
let text = format!("Hello {} {}", person.firstname, person.lastname);
response.send(text.as_slice());
}
server.post("/a/post/request", post_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate serialize;
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response };
#[deriving(Decodable, Encodable)]
struct Person {
firstname: String,
lastname: String,
}
fn main() {
let mut server = Nickel::new();
server.utilize(Nickel::json_body_parser());
fn post_handler (request: &Request, response: &mut Response) {
let person = request.json_as::<Person>().unwrap();
let text = format!("Hello {} {}", person.firstname, person.lastname);
response.send(text.as_slice());
}
server.post("/a/post/request", post_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
extern crate nickel;
use std::io::net::ip::Ipv4Addr;
use nickel::{ Nickel, Request, Response, Action };
fn main() {
let mut server = Nickel::new();
fn log (r: &Request, _r: &mut Response) -> Result<Action, NickelError> {
println!("logging request: {}", r.origin.request_uri);
Ok(Continue)
}
server.utilize(FromFn::new(log));
fn a_handler (_request: &Request, response: &mut Response) {
response.send("hello world");
}
server.get("/a/**/d", a_handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}
<html>
<body>
<h1>
Hello {{ name }}!
</h1>
</body>
</html>
extern crate nickel;
extern crate http;
use nickel::{ Nickel, Request, Response };
use std::io::net::ip::Ipv4Addr;
use std::collections::HashMap;
fn main() {
let mut server = Nickel::new();
fn handler (_request: &Request, response: &mut Response) {
let mut data = HashMap::<&str, &str>::new();
data.insert("name", "user");
response.render("examples/assets/template.tpl", &data);
}
server.get("/", handler);
server.listen(Ipv4Addr(127, 0, 0, 1), 6767);
}