Added all endpoints

This commit is contained in:
Julian Laubstein 2019-02-11 18:58:51 +01:00
parent 7caa714891
commit 1339784112
11 changed files with 67 additions and 8 deletions

View File

@ -1,5 +1,6 @@
[package]
name = "ragequit"
description = "A blazingly fast drop-in replacement for the Mastodon streaming api server"
version = "0.1.0"
authors = ["Julian Laubstein <contact@julianlaubstein.de>"]
edition = "2018"

1
rustfmt.toml Normal file
View File

@ -0,0 +1 @@
max_width = 120

5
src/api/http/direct.rs Normal file
View File

@ -0,0 +1,5 @@
use actix_web::{HttpRequest, Responder};
pub fn index(_req: HttpRequest) -> impl Responder {
"OMG! It works!"
}

9
src/api/http/hashtag.rs Normal file
View File

@ -0,0 +1,9 @@
use actix_web::{HttpRequest, Responder};
pub fn index(_req: HttpRequest) -> impl Responder {
"OMG! It works!"
}
pub fn local(_req: HttpRequest) -> impl Responder {
"OMG! It works!"
}

5
src/api/http/list.rs Normal file
View File

@ -0,0 +1,5 @@
use actix_web::{HttpRequest, Responder};
pub fn index(_req: HttpRequest) -> impl Responder {
"OMG! It works!"
}

5
src/api/http/mod.rs Normal file
View File

@ -0,0 +1,5 @@
pub mod direct;
pub mod hashtag;
pub mod list;
pub mod public;
pub mod user;

9
src/api/http/public.rs Normal file
View File

@ -0,0 +1,9 @@
use actix_web::{HttpRequest, Responder};
pub fn index(_req: HttpRequest) -> impl Responder {
"OMG! It works!"
}
pub fn local(_req: HttpRequest) -> impl Responder {
"OMG! It works!"
}

5
src/api/http/user.rs Normal file
View File

@ -0,0 +1,5 @@
use actix_web::{HttpRequest, Responder};
pub fn index(_req: HttpRequest) -> impl Responder {
"OMG! It works!"
}

2
src/api/mod.rs Normal file
View File

@ -0,0 +1,2 @@
pub mod http;
pub mod ws;

5
src/api/ws/mod.rs Normal file
View File

@ -0,0 +1,5 @@
use actix_web::{HttpRequest, Responder};
pub fn index(_req: HttpRequest) -> impl Responder {
"OMG! WebSocket works!"
}

View File

@ -1,4 +1,6 @@
use actix_web::{server, App, HttpRequest, Responder};
mod api;
use actix_web::{server, App};
use env_logger::Builder;
use log::info;
use std::net::SocketAddr;
@ -19,12 +21,22 @@ fn main() {
info!("starting streaming api server");
server::new(|| App::new().resource("/api/v1/streaming", |r| r.with(index)))
.bind(SocketAddr::from(([127, 0, 0, 1], args.port)))
.unwrap()
.run();
}
let addr: SocketAddr = ([127, 0, 0, 1], args.port).into();
fn index(_req: HttpRequest) -> impl Responder {
"OMG! It works!"
use api::{http, ws};
server::new(|| {
App::new()
.resource("/api/v1/streaming/user", |r| r.with(http::user::index))
.resource("/api/v1/streaming/public", |r| r.with(http::public::index))
.resource("/api/v1/streaming/public/local", |r| r.with(http::public::local))
.resource("/api/v1/streaming/direct", |r| r.with(http::direct::index))
.resource("/api/v1/streaming/hashtag", |r| r.with(http::hashtag::index))
.resource("/api/v1/streaming/hashtag/local", |r| r.with(http::hashtag::local))
.resource("/api/v1/streaming/list", |r| r.with(http::list::index))
.resource("/api/v1/streaming", |r| r.with(ws::index))
})
.bind(addr)
.unwrap()
.run();
}