Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
4446d9b879 | |||
ac8ba338bb |
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -761,7 +761,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "hoc"
|
||||
version = "0.9.1"
|
||||
version = "0.9.2"
|
||||
dependencies = [
|
||||
"actix-web 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"badge 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "hoc"
|
||||
version = "0.9.1"
|
||||
version = "0.9.2"
|
||||
authors = ["Valentin Brandl <vbrandl@riseup.net>"]
|
||||
edition = "2018"
|
||||
build = "build.rs"
|
||||
|
12
src/main.rs
12
src/main.rs
@ -17,7 +17,7 @@ mod service;
|
||||
mod statics;
|
||||
|
||||
use crate::{
|
||||
cache::{Cache, CacheState},
|
||||
cache::CacheState,
|
||||
error::{Error, Result},
|
||||
service::{Bitbucket, FormService, GitHub, Gitlab, Service},
|
||||
statics::{CLIENT, CSS, FAVICON, OPT, REPO_COUNT, VERSION_INFO},
|
||||
@ -56,6 +56,12 @@ struct State {
|
||||
cache: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct JsonResponse<'a> {
|
||||
head: &'a str,
|
||||
count: u64,
|
||||
}
|
||||
|
||||
fn pull(path: impl AsRef<Path>) -> Result<()> {
|
||||
let repo = Repository::open_bare(path)?;
|
||||
let mut origin = repo.find_remote("origin")?;
|
||||
@ -193,8 +199,8 @@ fn json_hoc<T: Service>(
|
||||
) -> impl Future<Item = HttpResponse, Error = Error> {
|
||||
let mapper = |r| match r {
|
||||
HocResult::NotFound => p404(),
|
||||
HocResult::Hoc { hoc, head, .. } => Ok(HttpResponse::Ok().json(Cache {
|
||||
head: head.into(),
|
||||
HocResult::Hoc { hoc, head, .. } => Ok(HttpResponse::Ok().json(JsonResponse {
|
||||
head: &head,
|
||||
count: hoc,
|
||||
})),
|
||||
};
|
||||
|
Reference in New Issue
Block a user