Permalink
Browse files

Update to rust HEAD.

  • Loading branch information...
1 parent 17ec8c6 commit 69d1eca16cc645cd20e5842320b8595147d80d53 @erickt committed Sep 30, 2012
Showing with 287 additions and 301 deletions.
  1. +11 −1 README.md
  2. 0 mongrel2.conf → example.conf
  3. +18 −27 example.rs
  4. +10 −11 mongrel2.rc
  5. +248 −262 mongrel2.rs
View
@@ -21,6 +21,16 @@ Install for developers:
% make deps
% make
- # If you want to run the tests and examples...
+Running the tests:
% make test && ./mongrel2
+
+Running the example:
+ # In one shell do:
+ % m2sh load --db config.sqlite --config example.conf
+ % m2sh start --db config.sqlite --host localhost
+
+ # In another shell do:
% make example && ./example
+
+ # In a third shell do:
+ % curl http://localhost:3000
File renamed without changes.
View
@@ -1,44 +1,35 @@
-use std;
-
-import io::println;
-import dvec::{dvec, extensions};
-import std::map;
-import std::map::hashmap;
-
-use zmq;
-import zmq::{context, to_str};
-
-use mongrel2;
-import mongrel2::connection;
+extern mod std;
+extern mod zmq;
+extern mod mongrel2;
fn main() {
- let ctx = alt zmq::init(1) {
- result::ok(ctx) { ctx }
- result::err(e) { fail e.to_str() }
+ let ctx = match zmq::init(1) {
+ Ok(ctx) => ctx,
+ Err(e) => fail e.to_str(),
};
let conn = mongrel2::connect(ctx,
- some("F0D32575-2ABB-4957-BC8B-12DAC8AFF13A"),
- ~["tcp://127.0.0.1:9998"],
- ~["tcp://127.0.0.1:9999"]);
+ Some(~"F0D32575-2ABB-4957-BC8B-12DAC8AFF13A"),
+ ~[~"tcp://127.0.0.1:9998"],
+ ~[~"tcp://127.0.0.1:9999"]);
loop {
- let request = conn.recv().get();
- println(#fmt("uuid: %s", *request.uuid));
- println(#fmt("id: %s", *request.id));
- println(#fmt("path: %s", *request.path));
+ let request = result::unwrap(conn.recv());
+ io::println(#fmt("uuid: %s", request.uuid));
+ io::println(#fmt("id: %s", request.id));
+ io::println(#fmt("path: %s", request.path));
for request.headers.each |k, vs| {
- for (*vs).each |v| {
- println(#fmt("header: %s => %s", k, *v));
+ for vs.each |v| {
+ io::println(#fmt("header: %s => %s", *k, *v));
}
};
- println(#fmt("body: %s", str::from_bytes(copy *request.body)));
+ io::println(#fmt("body: %s", str::from_bytes(request.body)));
conn.reply_http(request,
200u,
"OK",
- map::str_hash(),
- str::bytes("hello world!"));
+ mongrel2::Headers(),
+ str::to_bytes("hello world!"));
}
}
View
@@ -3,15 +3,14 @@
uuid = "f1bdda2b-0db7-42df-a40e-0decd4d56bb0")];
#[crate_type = "lib"];
-use std;
-use zmq;
-use tnetstring;
+extern mod std;
+extern mod zmq;
+extern mod tnetstring;
-import result::{result, ok, err};
-import dvec::{dvec, extensions};
-import std::json;
-import json::to_str;
-import std::map;
-import std::map::hashmap;
-import zmq::{context, socket, to_str};
-import tnetstring::tnetstring;
+use dvec::DVec;
+use send_map::linear::LinearMap;
+use std::json;
+use std::json::{Json, ToStr};
+
+use zmq::{Context, Socket, to_str};
+use tnetstring::TNetString;
Oops, something went wrong. Retry.

0 comments on commit 69d1eca

Please sign in to comment.