Self-contained System for Geolocation API calls.
The Geo-Providers can be configured via web ui, including monthly payload limits.
Still under heavy construction
This application will be just rudimentary and mostly to learn Rust and the Rocket framework.
-
Rust programming language with Rocket webframework
-
Diesel ORM and SQLx toolkit
-
Self-contained System with Web-based Userinterface
-
support for several Geolocation providers
-
each registered GEO provider with own configureable monthly payload limits
-
configuration based on SQLite3 database
-
template-based UI with Handlebars, JS and CSS support
-
scaleable, clean architecture
-
ReSTfull
-
Secured (XSS, ...)
-
User authentication, rights and roles
-
tbd.
Version Date Developer Comments 0.1.0 2023-12-16 RZheng created
loads the landing page with some explanations
/
Returns: HTML page
list all providers from database
GET /providers
Parameter | Type | Description |
---|---|---|
none |
-/- |
list all configured providers |
Returns: JSON array
GET /provider/${id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Id of provider to fetch |
Returns: JSON
Create (add) a new provider to the database
POST /create/${JSON data}
Parameter | Type | Description |
---|---|---|
name |
string |
Required. name of provider |
description |
string |
Required. short description of provider |
api_key |
string |
Required. API key |
counter_limit |
string |
Required. payload limit per month |
counter |
string |
Required. initial payload (eg. 0) |
To run this project, you will need to add the following environment variables to your .env file (see example: env_prod)
DATABASE_URL="sqlite://data.db"
Manage the SQLite3 database with Diesel:
diesel setup
diesel migration generate create_tasks
define up.sql
CREATE TABLE IF NOT EXISTS geo_provider
(
id INTEGER PRIMARY KEY NOT NULL,
name TEXT NOT NULL UNIQUE,
description TEXT NOT NULL,
api_key TEXT NOT NULL,
counter_limit TEXT NOT NULL,
counter TEXT NOT NULL,
date_time integer not NULL
);
define down.sql
DROP TABLE geo_provider;
create database
diesel migration run
cargo build --release
the following CORS are defined (in main.rs):
response.set*header(Header::new("Access-Control-Allow-Origin", "*"));
response.set*header(Header::new("Access-Control-Allow-Methods", "POST, GET, PATCH, OPTIONS", ));
response.set_header(Header::new("Access-Control-Allow-Headers", "*"));
response.set_header(Header::new("Access-Control-Allow-Credentials", "true"));
response.set_header(Header::new("Strict-Transport-Security", "max-age=63072000"));
please be aware of "Strict-Transport-Security"
Startpage
create / add provider
list all registered providers
🖖