aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.rs33
1 files changed, 28 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index be109d0..595ce3b 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,25 +1,48 @@
1//! # Gradecoin 1//! # Services
2//! 2//!
3//! ## Services 3//! All of these endpoints will be served with the URL prefix of a given network.
4//! ### /register 4//! For example, if URL prefix is `testnet`, `/register` is found at `/testnet/register`.
5//!
6//! ## /register
5//! - Student creates their own 2048 bit RSA `keypair` 7//! - Student creates their own 2048 bit RSA `keypair`
6//! - Downloads `Gradecoin`'s Public Key from Moodle 8//! - Downloads `Gradecoin`'s Public Key from Moodle
7//! - Encrypts their JSON wrapped `Public Key` and `Student ID` using Gradecoin's Public Key 9//! - Encrypts their JSON wrapped `Public Key` and `Student ID` using Gradecoin's Public Key
8//! - Their public key is now in our Db under [`block::User::public_key`] and can be used to sign their JWT's during requests 10//! - Their public key is now in our Db under [`block::User::public_key`] and can be used to sign their JWT's during requests
9//! 11//!
10//! ### /transaction 12//! ## /transaction
11//! - offer a [`block::Transaction`] - POST request 13//! - offer a [`block::Transaction`] - POST request
12//! - The request should have `Authorization` 14//! - The request should have `Authorization`
13//! - The request header should be signed by the Public Key of the `by` field in the transaction 15//! - The request header should be signed by the Public Key of the `by` field in the transaction
14//! - fetch the list of `Transaction`s - GET request 16//! - fetch the list of `Transaction`s - GET request
15//! 17//!
16//! ### /block 18//! ## /block
17//! - offer a [`block::Block`] - POST request 19//! - offer a [`block::Block`] - POST request
18//! - The request should have `Authorization` 20//! - The request should have `Authorization`
19//! - The [`block::Block::transaction_list`] of the block should be a subset of [`block::Db::pending_transactions`] 21//! - The [`block::Block::transaction_list`] of the block should be a subset of [`block::Db::pending_transactions`]
20//! - fetch the last accepted [`block::Block`] - GET request 22//! - fetch the last accepted [`block::Block`] - GET request
21//! 23//!
22//! `Authorization`: The request header should have Bearer JWT.Token signed with Student Public Key 24//! `Authorization`: The request header should have Bearer JWT.Token signed with Student Public Key
25//!
26//! ## /config
27//! - Get the current [`config::Config`] as JSON - GET request
28//!
29//! # Configuration
30//!
31//! The default configuration file if `config.yaml`, which will run if no command line arguments are given.
32//!
33//! You can give one or more configuration files as command line arguments.
34//! This will run all of them at the same time.
35//! Make sure that the names and URL prefixes don't clash, otherwise it will lead to undefined behavior.
36//!
37//! Example:
38//! ```sh
39//! # Run both the main network (at /) and testnet (at /testnet)
40//! # For example, register for main network at `localhost:8080/register`,
41//! # testnet network at `localhost:8080/testnet/register`
42//! $ cargo run config.yaml testnet.yaml
43//! ```
44//!
45//! See [`config::Config`] struct for more information about the configurable fields.
23#![warn(clippy::all, clippy::pedantic)] 46#![warn(clippy::all, clippy::pedantic)]
24#![allow(clippy::unused_async)] 47#![allow(clippy::unused_async)]
25 48