1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! A library with components to implement a REST API.
//!
//! The goal of this crate is to provide:
//!
//!   - boilerplate to parse environment and run a Rocket server
//!   - glue code for Rocket and Diesel to use a database in the web service
//!   - standard API replies
//!
//!  That allows an API or a back-end web server to focus on requests and data model.
//!
//!  # Examples
//!
//!  A simple server serving a 200 ALIVE response on /status :
//!
//!  ```no_run
//!  use limiting_factor::kernel::DefaultApplication;
//!
//!  pub fn run () {
//!      let routes = routes![
//!          status,
//!      ];
//!
//!      DefaultApplication::start_application(routes);
//!  }
//!
//!  #[get("/status")]
//!  pub fn status() -> &'static str {
//!      "ALIVE"
//!  }
//!  ```
//!
//! Replacing `DefaultApplication` by `MinimalApplication` allows to use a lighter version
//! of the library without Diesel dependencies or database use.

#[cfg(feature = "pgsql")]
extern crate diesel;
extern crate dotenv;
#[macro_use]
extern crate log;
#[cfg(feature = "pgsql")]
extern crate r2d2;
extern crate rocket;
extern crate rocket_contrib;
#[cfg(feature = "serialization")]
extern crate serde;

/*   -------------------------------------------------------------
     Public modules offered by this crate
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

pub mod api;
pub mod config;
pub mod kernel;

/*   -------------------------------------------------------------
     Optional public features modules offered by this crate
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

#[cfg(feature = "pgsql")]
pub mod database;

/*   -------------------------------------------------------------
     Custom types
     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

pub type ErrorResult<T> =  Result<T, Box<dyn std::error::Error>>;