mirror of
https://github.com/bspeice/nutone
synced 2024-12-21 21:28:10 -05:00
Initial commit
Includes some unimportant files
This commit is contained in:
parent
3bc399c80a
commit
474995194b
BIN
.Cargo.toml.swp
Normal file
BIN
.Cargo.toml.swp
Normal file
Binary file not shown.
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
target
|
||||
Cargo.lock
|
||||
target
|
11
Cargo.toml
Normal file
11
Cargo.toml
Normal file
@ -0,0 +1,11 @@
|
||||
[package]
|
||||
name = "nutone"
|
||||
version = "0.1.0"
|
||||
authors = ["Bradlee Speice <bradlee.speice@gmail.com>"]
|
||||
|
||||
[dependencies]
|
||||
html5ever = "*"
|
||||
rss = "*"
|
||||
hyper = "*"
|
||||
iron = "*"
|
||||
router = "*"
|
20
src/bassdrive.rs
Normal file
20
src/bassdrive.rs
Normal file
@ -0,0 +1,20 @@
|
||||
extern crate hyper;
|
||||
extern crate rss;
|
||||
|
||||
use rss::Channel;
|
||||
use std::str::FromStr;
|
||||
|
||||
use broadcast::Broadcaster;
|
||||
|
||||
pub struct BassDrive {
|
||||
pub url: String
|
||||
}
|
||||
|
||||
impl BassDrive {
|
||||
}
|
||||
|
||||
impl Broadcaster for BassDrive {
|
||||
fn broadcast(&self) -> Channel {
|
||||
Channel::from_str("").unwrap()
|
||||
}
|
||||
}
|
18
src/broadcast.rs
Normal file
18
src/broadcast.rs
Normal file
@ -0,0 +1,18 @@
|
||||
extern crate rss;
|
||||
extern crate hyper;
|
||||
|
||||
use hyper::server::{Request, Response};
|
||||
use rss::Channel;
|
||||
|
||||
pub trait Broadcaster {
|
||||
fn broadcast(&self) -> Channel;
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn build_broadcast<T: Broadcaster>(b: T) -> Box<Fn(Request, Response)> {
|
||||
let channel = b.broadcast();
|
||||
|
||||
Box::new(move |_: Request, res: Response| {
|
||||
res.send(channel.to_string().as_bytes());
|
||||
})
|
||||
}
|
31
src/main.rs
Normal file
31
src/main.rs
Normal file
@ -0,0 +1,31 @@
|
||||
extern crate iron;
|
||||
extern crate router;
|
||||
|
||||
use iron::Handler;
|
||||
use iron::status;
|
||||
use iron::IronResult;
|
||||
use iron::Response;
|
||||
use iron::Request;
|
||||
use iron::Iron;
|
||||
use router::Router;
|
||||
|
||||
struct EchoHandler {
|
||||
message: String
|
||||
}
|
||||
|
||||
impl Handler for EchoHandler {
|
||||
fn handle(&self, _: &mut Request) -> IronResult<Response> {
|
||||
Ok(Response::with((status::Ok, self.message.clone())))
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let echo = EchoHandler {
|
||||
message: "FINALLY ARE YOU FREAKING KIDDING ME".to_string()
|
||||
};
|
||||
|
||||
let mut router = Router::new();
|
||||
router.get("/", echo, "index");
|
||||
|
||||
Iron::new(router).http("localhost:3000").unwrap();
|
||||
}
|
47
src/main_hyper.rs.bak
Normal file
47
src/main_hyper.rs.bak
Normal file
@ -0,0 +1,47 @@
|
||||
extern crate hyper;
|
||||
extern crate reroute;
|
||||
extern crate rss;
|
||||
|
||||
use hyper::server::{Server, Request, Response, Handler};
|
||||
use reroute::{Router, Captures};
|
||||
|
||||
mod broadcast;
|
||||
mod bassdrive;
|
||||
|
||||
#[allow(unused)]
|
||||
fn http_404(req: Request, res: Response) {
|
||||
res.send(format!("Couldn't find URL: {}", req.uri).as_bytes());
|
||||
}
|
||||
|
||||
struct EchoHandler {
|
||||
response: String
|
||||
}
|
||||
|
||||
impl EchoHandler {
|
||||
fn handle(&self, _: Request, res: Response, _: Captures) {
|
||||
res.send(self.response.as_bytes());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[allow(unused)]
|
||||
fn main() {
|
||||
let mut router = Router::new();
|
||||
|
||||
let echo = EchoHandler {
|
||||
response: "Hello, world!".to_string()
|
||||
};
|
||||
router.get(r"/hello", echo);
|
||||
|
||||
/*
|
||||
router.get(r"/hello", build_broadcast(
|
||||
BassDrive {
|
||||
url: "http://archives.bassdrivearchive.com/6%20-%20Saturday/Electronic%20Warfare%20-%20The%20Overfiend/"
|
||||
})
|
||||
);
|
||||
*/
|
||||
router.add_not_found(http_404);
|
||||
router.finalize().unwrap();
|
||||
|
||||
Server::http("0.0.0.0:3000").unwrap().handle(router).unwrap();
|
||||
}
|
Loading…
Reference in New Issue
Block a user