Merge pull request #1 from tootsuite/setup-housekeeping

Initial setup/housekeeping
This commit is contained in:
Daniel Sockwell 2019-03-05 09:28:27 -05:00 committed by GitHub
commit 36c2734c86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 26 additions and 15 deletions

View File

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

View File

@ -2,5 +2,5 @@ use crate::AppState;
use actix_web::{HttpRequest, Responder};
pub fn index(_req: HttpRequest<AppState>) -> impl Responder {
"OMG! It works!"
"placeholder response from direct::index"
}

View File

@ -2,9 +2,9 @@ use crate::AppState;
use actix_web::{HttpRequest, Responder};
pub fn index(_req: HttpRequest<AppState>) -> impl Responder {
"OMG! It works!"
"placeholder response from hashtag::index"
}
pub fn local(_req: HttpRequest<AppState>) -> impl Responder {
"OMG! It works!"
"placeholder response from hashtag::local"
}

View File

@ -2,5 +2,5 @@ use crate::AppState;
use actix_web::{HttpRequest, Responder};
pub fn index(_req: HttpRequest<AppState>) -> impl Responder {
"OMG! It works!"
"placeholder response from list::index"
}

View File

@ -2,9 +2,9 @@ use crate::AppState;
use actix_web::{HttpRequest, Responder};
pub fn index(_req: HttpRequest<AppState>) -> impl Responder {
"OMG! It works!"
"placeholder response from public::index"
}
pub fn local(_req: HttpRequest<AppState>) -> impl Responder {
"OMG! It works!"
"placeholder response from public::local"
}

View File

@ -2,5 +2,5 @@ use crate::AppState;
use actix_web::{HttpRequest, Responder};
pub fn index(_req: HttpRequest<AppState>) -> impl Responder {
"OMG! It works!"
"placeholder response from user::index"
}

View File

@ -15,18 +15,26 @@ impl Actor for WebsocketActor {
/// Handler for ws::Message message
impl StreamHandler<ws::Message, ws::ProtocolError> for WebsocketActor {
fn started(&mut self, ctx: &mut Self::Context) {
ctx.run_interval(Duration::from_secs(HEARTBEAT_INTERVAL_SECONDS), |_, inner_ctx| {
inner_ctx.ping("");
});
ctx.run_interval(
Duration::from_secs(HEARTBEAT_INTERVAL_SECONDS),
|_, inner_ctx| {
inner_ctx.ping("Ping from StreamHandler");
},
);
}
// This appears to be an echo server based on the actix_web documentation
// We won't actually need echo functionality in the final server
fn handle(&mut self, msg: ws::Message, ctx: &mut Self::Context) {
debug!("Message {:?}", msg);
let red = ctx.state().redis.send(Command(RespValue::SimpleString("GET".into())));
let red = ctx
.state()
.redis
.send(Command(RespValue::SimpleString("GET".into())));
match msg {
ws::Message::Pong(msg) => debug!("{}", msg),
ws::Message::Pong(msg) => debug!("matched: {}", msg),
ws::Message::Text(text) => ctx.text(text),
_ => (),
}

View File

@ -91,6 +91,10 @@ fn cors_middleware() -> Cors {
Cors::build()
.allowed_origin("*")
.allowed_methods(vec!["GET", "OPTIONS"])
.allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT, header::CACHE_CONTROL])
.allowed_headers(vec![
header::AUTHORIZATION,
header::ACCEPT,
header::CACHE_CONTROL,
])
.finish()
}

View File

@ -1 +1 @@
pub mod auth;
pub mod auth;