Compare commits

..

No commits in common. "main" and "refactor" have entirely different histories.

5 changed files with 15 additions and 46 deletions

View file

@ -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

View file

@ -2,8 +2,7 @@ FROM docker.io/lukemathwalker/cargo-chef:latest-rust-1 AS chef
WORKDIR /app WORKDIR /app
FROM chef AS planner FROM chef AS planner
COPY Cargo.* . COPY . .
ADD src src
RUN cargo chef prepare --recipe-path recipe.json RUN cargo chef prepare --recipe-path recipe.json
FROM chef AS builder FROM chef AS builder

View file

@ -15,7 +15,7 @@
} }
header { header {
background: #1CD4FF; background: #007BFF;
color: #ffffff; color: #ffffff;
padding: 10px 20px; padding: 10px 20px;
text-align: center; text-align: center;
@ -32,7 +32,7 @@
footer { footer {
text-align: center; text-align: center;
padding: 10px 0; padding: 10px 0;
background: #1CD4FF; background: #007BFF;
color: white; color: white;
/*position: fixed;*/ /*position: fixed;*/
bottom: 0; bottom: 0;
@ -94,13 +94,11 @@
<p>The digital elevation data comes from ESA's Copernicus program.</p> <p>The digital elevation data comes from ESA's Copernicus program.</p>
<h3>Rate limits</h3> <h3>Rate limits</h3>
<p>Don't be an idiot. Less than 10/s is okay</p> <p>Don't be an idiot. Less than 10/s is okay</p>
<h3>Source code</h3>
<p><a href="https://forge.k3s.fr/elevation-api-eu/api-server">https://forge.k3s.fr/elevation-api-eu/api-server</a></p>
<h3>Contact</h3> <h3>Contact</h3>
<p>For more information, you can reach me at f@vi-di.fr. Patches welcome!</p> <p>For more information, you can reach me at f@vi-di.fr</p>
</section> </section>
<footer> <footer>
<p>© 2024 <a href="https://frank.villaro-dixon.eu">Frank Villaro-Dixon</a>. No rights reserved. Made with love in 🇨🇭 and 🇫🇷</p> <p>© 2024 Frank Villaro-Dixon. No rights reserved</p>
</footer> </footer>
</body> </body>

View file

@ -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;
} }

View file

@ -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 };