Page MenuHomeDevCentral

D1844.diff
No OneTemporary

D1844.diff

diff --git a/LICENSE b/LICENSE
new file mode 100644
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,25 @@
+Copyright 2018 Sébastien Santoro aka Dereckson
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -1,9 +1,23 @@
The **limiting-factor** crate offers facilities to implement a REST API.
+## Goal
+
The goal of this library is to provide:
- glue code for Rocket and Diesel
- standard API replies
- - boilerplate to parse environment and run a server
+ - boilerplate to parse environment to extract configuration and run a server
+
+That allows an API or a back-end web server to focus on requests and data model,
+and to maintain helper methods as a separate library.
+
+## Dependencies
+
+* Diesel, as PostgreSQL ORM, with r2d2 support to pool connections
+* Rocket, as web framework
+* Chrono, for date and time types
+
+## Credits
-That allows an API or a back-end web server to focus on requests and data model, and to maintain helper methods as a separate library.
+The glue code to use Rocket with Diesel is adapted from the Rocket guide.
+See https://rocket.rs/guide/state/#databases. Guide author: Sergio Benitez.
diff --git a/src/api/mod.rs b/src/api/mod.rs
--- a/src/api/mod.rs
+++ b/src/api/mod.rs
@@ -1,4 +1,4 @@
-//! # API module
+//! # Utilities for API.
//!
//! This module provides useful code to create easily APIs.
diff --git a/src/api/replies.rs b/src/api/replies.rs
--- a/src/api/replies.rs
+++ b/src/api/replies.rs
@@ -1,4 +1,4 @@
-//! # API module
+//! # API standard and JSON responses.
//!
//! This module provides useful traits and methods to craft API replies from an existing type.
diff --git a/src/config.rs b/src/config.rs
--- a/src/config.rs
+++ b/src/config.rs
@@ -1,4 +1,6 @@
-//! This module allows to configure the API.
+//! # Service configuration.
+//!
+//! This module allows to configure the service.
//!
//! It provides a Config trait to build custom configuration implementation.
//!
diff --git a/src/kernel.rs b/src/kernel.rs
--- a/src/kernel.rs
+++ b/src/kernel.rs
@@ -1,4 +1,4 @@
-//! # API module
+//! # Service execution utilities.
//!
//! Provides methods to start the server and handle the application
@@ -112,9 +112,10 @@
/// # Exit codes
///
/// The software will exit with the following error codes:
- /// 0: Exits gracefully (but currently we don't have a signal to ask the server to shutdown)
- /// 1: Error during the application run (e.g. routes conflict or Rocket fairings issues)
- /// 2: Error parsing the configuration (e.g. no database URL has been defined)
+ ///
+ /// - 0: Graceful exit (currently not in use, as the application never stops)
+ /// - 1: Error during the application run (e.g. routes conflict or Rocket fairings issues)
+ /// - 2: Error parsing the configuration (e.g. no database URL has been defined)
pub fn start_application (routes: Vec<Route>) {
info!(target: "runner", "Server initialized.");
diff --git a/src/lib.rs b/src/lib.rs
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,3 +1,34 @@
+//! 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"
+//! }
+//! ```
+
extern crate diesel;
extern crate dotenv;
#[macro_use] extern crate log;

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 6, 14:50 (17 h, 43 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2232023
Default Alt Text
D1844.diff (5 KB)

Event Timeline