|
@@ -1,12 +1,18 @@
|
|
|
extern crate may;
|
|
|
extern crate num_cpus;
|
|
|
#[macro_use]
|
|
|
+extern crate serde_derive;
|
|
|
extern crate serde_json;
|
|
|
extern crate may_minihttp;
|
|
|
|
|
|
use std::io;
|
|
|
use may_minihttp::{HttpServer, HttpService, Request, Response};
|
|
|
|
|
|
+#[derive(Serialize)]
|
|
|
+struct Message<'a> {
|
|
|
+ message: &'a str,
|
|
|
+}
|
|
|
+
|
|
|
struct Techempower;
|
|
|
|
|
|
impl HttpService for Techempower {
|
|
@@ -18,7 +24,7 @@ impl HttpService for Techempower {
|
|
|
"/json" => {
|
|
|
resp.header("Content-Type", "application/json");
|
|
|
*resp.body_mut() =
|
|
|
- serde_json::to_vec(&json!({"message": "Hello, World!"})).unwrap();
|
|
|
+ serde_json::to_vec(&Message { message: "Hello, World!" }).unwrap();
|
|
|
}
|
|
|
"/plaintext" => {
|
|
|
resp.header("Content-Type", "text/plain")
|