Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/daemon/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,21 @@ pub struct Message {
message: String
}

#[derive(Serialize)]
pub struct InfoData {
implementation: String,
version: String,
vendor: String,
author: String
}

fn help(_req: HttpRequest) -> impl Responder {
"Sighting Daemon, written by Sebastien Tricaud, (C) Devo Inc. 2019
REST Endpoints:
\t/w: write
\t/r: read
\t/c: configure
\t/i: info
"
}

Expand Down Expand Up @@ -128,11 +137,13 @@ fn main() {
// w -> write
// r -> read
// c -> config (push all to disk, alway in memory, both)
// i -> info
// untyped -> things that have an incorrect type match
HttpServer::new(move || { App::new().data(sharedstate.clone())
.route("/r/*", web::get().to(read))
.route("/w/*", web::get().to(write))
.route("/c/*", web::get().to(configure))
.route("/i", web::get().to(info))
.default_service(web::to(help))
})
.bind_ssl(server_address, builder)
Expand All @@ -142,3 +153,13 @@ fn main() {
}

}

fn info(_req: HttpRequest) -> impl Responder {
let infoData = InfoData {
implementation: String::from("SightingDB"),
version: String::from("0.0.1"),
vendor: String::from("Devo"),
author: String::from("Sebastien Tricaud")
};
return HttpResponse::Ok().json(&infoData);
}