Skip to content

jak0b/gpx-json-data-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GPX to JSON HTTP Server

This Go application sets up a secure HTTPS server that serves GPX files converted to JSON format. It allows authenticated users to request specific GPX files via HTTP endpoints and receive their JSON representations.

The server is used together with the Grafana Infinity plugin, which retrieves the JSON data and displays a comparison of device measurements.


Features

  • Serves multiple GPX files stored in a specified directory
  • Converts GPX files to JSON on-the-fly
  • Supports Basic Authentication for access control
  • Enforces HTTPS using SSL certificates
  • Easily configurable via command-line flags

Prerequisites

  • Go 1.16 or higher
  • SSL certificate and key files (e.g., certs/example.com.crt and certs/example.com.key)
  • GPX files stored in a directory (default: data/)

Setup

  1. Install Go

    Ensure Go is installed on your system. Download from golang.org if necessary.

  2. Prepare SSL Certificates

    Obtain or generate SSL certificate and key files:

    • Place them in the certs/ directory or update the paths accordingly.
    • Example files: certs/example.com.crt and certs/example.com.key
  3. Place GPX Files

    Put your GPX files into the data directory (default: data/). The server will automatically serve files based on the directory structure.

  4. Configure Authentication and Server Settings (Optional)

    You can customize:

    • Basic Auth username and password
    • Data directory
    • SSL certificate and key files

Usage

Compile the application:

go build

Run with default settings:

./gpx-json-data-server

Run with custom flags (example):

./gpx-json-data-server \
  -basic-auth-username=myuser \
  -basic-auth-password=mypassword \
  -ssl-cert-file=path/to/cert.crt \
  -ssl-key-file=path/to/key.key \

How It Works

  • The server reads configuration flags, including authentication credentials and file paths.
  • It scans the specified data directory and maps files to HTTP routes.
  • For each route:
    • Checks for Basic Authentication.
    • Converts the GPX file to JSON format.
    • Serves the JSON response over HTTPS.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages