Compare commits
No commits in common. "f781a392de5e5fa95a335e42860ca5191293d940" and "a5b97b67a8d57ff7629cca8bea19f337d290f5ec" have entirely different histories.
f781a392de
...
a5b97b67a8
4 changed files with 9 additions and 37 deletions
|
@ -1,31 +0,0 @@
|
||||||
name: ci
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- "cicd"
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
docker:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
- name: Set up QEMU
|
|
||||||
uses: docker/setup-qemu-action@v3
|
|
||||||
- name: Set up Docker Buildx
|
|
||||||
uses: docker/setup-buildx-action@v3
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: forge.k3s.fr
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
||||||
- name: Build and push
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
tags: forge.k3s.fr/elevation-api-eu/server:latest
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl DatasetRepository {
|
||||||
info!("Will open {full_filename} because not in cache!");
|
info!("Will open {full_filename} because not in cache!");
|
||||||
let ds = Dataset::open(full_filename.clone());
|
let ds = Dataset::open(full_filename.clone());
|
||||||
match ds {
|
match ds {
|
||||||
Err(_) => {
|
Err(x) => {
|
||||||
error!("File not present");
|
error!("File not present");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
11
src/main.rs
11
src/main.rs
|
@ -10,7 +10,7 @@ use axum::{
|
||||||
use axum_macros::debug_handler;
|
use axum_macros::debug_handler;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
use serde::ser::SerializeSeq;
|
use serde::ser::{SerializeSeq, Serializer};
|
||||||
use serde::{Deserialize, Deserializer, Serialize};
|
use serde::{Deserialize, Deserializer, Serialize};
|
||||||
use serde_qs::axum::{QsQueryConfig, QsQueryRejection};
|
use serde_qs::axum::{QsQueryConfig, QsQueryRejection};
|
||||||
use tower_http::trace::TraceLayer;
|
use tower_http::trace::TraceLayer;
|
||||||
|
@ -105,8 +105,8 @@ async fn main() {
|
||||||
.with_state(cache)
|
.with_state(cache)
|
||||||
.layer(
|
.layer(
|
||||||
TraceLayer::new_for_http()
|
TraceLayer::new_for_http()
|
||||||
.make_span_with(trace::DefaultMakeSpan::new().level(Level::INFO))
|
.make_span_with(trace::DefaultMakeSpan::new().level(Level::DEBUG))
|
||||||
.on_response(trace::DefaultOnResponse::new().level(Level::INFO)),
|
.on_response(trace::DefaultOnResponse::new().level(Level::DEBUG)),
|
||||||
)
|
)
|
||||||
.layer(Extension(QsQueryConfig::new(5, false).error_handler(
|
.layer(Extension(QsQueryConfig::new(5, false).error_handler(
|
||||||
|err| {
|
|err| {
|
||||||
|
@ -130,6 +130,9 @@ async fn get_elevation(
|
||||||
query_opts: Query<Opts>,
|
query_opts: Query<Opts>,
|
||||||
Path((lat, lon)): Path<(f64, f64)>,
|
Path((lat, lon)): Path<(f64, f64)>,
|
||||||
) -> Response {
|
) -> Response {
|
||||||
|
println!("lat: {}, lon: {}", lat, lon);
|
||||||
|
println!("query_opts: {:?}", query_opts);
|
||||||
|
|
||||||
let ele;
|
let ele;
|
||||||
match dem::elevation_from_coordinates(&dsr, lat, lon).await {
|
match dem::elevation_from_coordinates(&dsr, lat, lon).await {
|
||||||
Ok(x) => match x {
|
Ok(x) => match x {
|
||||||
|
@ -144,7 +147,7 @@ async fn get_elevation(
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct Ele {
|
struct Ele {
|
||||||
elevation: f64,
|
elevation: f64,
|
||||||
}
|
};
|
||||||
|
|
||||||
if query_opts.json {
|
if query_opts.json {
|
||||||
let r = Ele { elevation: ele };
|
let r = Ele { elevation: ele };
|
||||||
|
|
Loading…
Reference in a new issue