Compare commits
2 Commits
bddbdc06f3
...
28d4cf4ad5
Author | SHA1 | Date |
---|---|---|
Natty | 28d4cf4ad5 | |
Natty | 82bd8d5143 |
|
@ -17,7 +17,7 @@ WORKDIR /magnetar
|
||||||
|
|
||||||
COPY ./ .
|
COPY ./ .
|
||||||
|
|
||||||
RUN cargo build --release
|
RUN cargo build --release --frozen
|
||||||
|
|
||||||
FROM docker.io/debian:bullseye-slim
|
FROM docker.io/debian:bullseye-slim
|
||||||
|
|
||||||
|
|
|
@ -125,7 +125,7 @@ pub struct MagnetarData {
|
||||||
fn env_database_url() -> String {
|
fn env_database_url() -> String {
|
||||||
std::env::var("MAG_C_DATABASE_URL")
|
std::env::var("MAG_C_DATABASE_URL")
|
||||||
.or_else(|_| std::env::var("DATABASE_URL"))
|
.or_else(|_| std::env::var("DATABASE_URL"))
|
||||||
.expect("MAG_C_HOST, DATABASE_URL or \"data.database_url\" in the default configuration must be set")
|
.expect("MAG_C_DATABASE_URL, DATABASE_URL or \"data.database_url\" in the default configuration must be set")
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for MagnetarData {
|
impl Default for MagnetarData {
|
||||||
|
|
|
@ -9,6 +9,7 @@ use magnetar_nodeinfo::version_1_0::{
|
||||||
use magnetar_nodeinfo::version_2_0::NodeInfo20;
|
use magnetar_nodeinfo::version_2_0::NodeInfo20;
|
||||||
use magnetar_nodeinfo::version_2_1::{NodeInfo21, NodeInfo21Software};
|
use magnetar_nodeinfo::version_2_1::{NodeInfo21, NodeInfo21Software};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
use serde_json::{json, Value};
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
const NODEINFO_PATH: &str = "/nodeinfo";
|
const NODEINFO_PATH: &str = "/nodeinfo";
|
||||||
|
@ -19,10 +20,8 @@ pub struct NodeInfoLink {
|
||||||
href: String,
|
href: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_nodeinfo(
|
pub async fn handle_nodeinfo(State(config): State<&'static MagnetarConfig>) -> Json<Value> {
|
||||||
State(config): State<&'static MagnetarConfig>,
|
let links = vec![
|
||||||
) -> Json<Vec<NodeInfoLink>> {
|
|
||||||
Json(vec![
|
|
||||||
NodeInfoLink {
|
NodeInfoLink {
|
||||||
href: format!(
|
href: format!(
|
||||||
"{}://{}/nodeinfo/2.0",
|
"{}://{}/nodeinfo/2.0",
|
||||||
|
@ -37,7 +36,11 @@ pub async fn handle_nodeinfo(
|
||||||
),
|
),
|
||||||
rel: RelNodeInfo21.rel(),
|
rel: RelNodeInfo21.rel(),
|
||||||
},
|
},
|
||||||
])
|
];
|
||||||
|
|
||||||
|
let links_serialized = serde_json::to_value(links).unwrap();
|
||||||
|
|
||||||
|
Json(json!({ "links": links_serialized }))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_nodeinfo_21(State(config): State<&'static MagnetarConfig>) -> Json<NodeInfo21> {
|
pub async fn handle_nodeinfo_21(State(config): State<&'static MagnetarConfig>) -> Json<NodeInfo21> {
|
||||||
|
|
Loading…
Reference in New Issue