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.
- 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
- Go 1.16 or higher
- SSL certificate and key files (e.g.,
certs/example.com.crtandcerts/example.com.key) - GPX files stored in a directory (default:
data/)
-
Install Go
Ensure Go is installed on your system. Download from golang.org if necessary.
-
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.crtandcerts/example.com.key
- Place them in the
-
Place GPX Files
Put your GPX files into the data directory (default:
data/). The server will automatically serve files based on the directory structure. -
Configure Authentication and Server Settings (Optional)
You can customize:
- Basic Auth username and password
- Data directory
- SSL certificate and key files
Compile the application:
go buildRun with default settings:
./gpx-json-data-serverRun 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 \- 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.