Skip to content

Commit

Permalink
Merge pull request #37 from mozilla-services/feat/29
Browse files Browse the repository at this point in the history
feat: add dockerflow requirements
  • Loading branch information
jrconlin authored Jul 18, 2018
2 parents d5e5b5d + 13c0fff commit 0e31edc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/server/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ pub enum RequestType {
Websocket,
Status,
LogCheck,
LBHeartBeat,
Version,
}

impl Dispatch {
Expand Down Expand Up @@ -75,7 +77,9 @@ impl Future for Dispatch {
RequestType::Websocket
} else {
match req.path {
Some(ref path) if path.starts_with("/status") => RequestType::Status,
Some(ref path) if path.starts_with("/status") || *path == "/__heartbeat__" => RequestType::Status,
Some(ref path) if *path == "/__lbheartbeat__" => RequestType::LBHeartBeat,
Some(ref path) if *path == "/__version__" => RequestType::Version,
Some(ref path) if path.starts_with("/v1/err/crit") => RequestType::LogCheck,
_ => {
debug!("unknown http request {:?}", req);
Expand Down
10 changes: 10 additions & 0 deletions src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,8 @@ impl Server {
let client = request.and_then(move |(socket, request)| -> MyFuture<_> {
match request {
RequestType::Status => write_status(socket),
RequestType::LBHeartBeat => write_json(socket, StatusCode::Ok, serde_json::Value::from("")),
RequestType::Version => write_version_file(socket),
RequestType::LogCheck => write_log_check(socket),
RequestType::Websocket => {
// Perform the websocket handshake on each
Expand Down Expand Up @@ -946,6 +948,14 @@ fn write_status(socket: WebpushIo) -> MyFuture<()> {
)
}

/// Return a static copy of `version.json` from compile time.
pub fn write_version_file(socket: WebpushIo) -> MyFuture<()> {
write_json(
socket,
StatusCode::Ok,
serde_json::Value::from(include_str!("../../version.json")))
}

fn write_log_check(socket: WebpushIo) -> MyFuture<()> {
let status = StatusCode::ImATeapot;
let code: u16 = status.into();
Expand Down

0 comments on commit 0e31edc

Please sign in to comment.