Page MenuHomeDevCentral

D3713.diff
No OneTemporary

D3713.diff

diff --git a/.gitignore b/.gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,3 @@
-/target
+target/
**/*.rs.bk
Cargo.lock
diff --git a/Cargo.toml b/Cargo.toml
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,37 +1,5 @@
-[package]
-name = "limiting-factor"
-version = "0.8.0"
-authors = [
- "Sébastien Santoro <dereckson@espace-win.org>",
+[workspace]
+resolver = "3"
+members = [
+ "rocket-legacy",
]
-description = "Library to create a REST API with Diesel and Rocket"
-readme = "README.md"
-keywords = [
- "Diesel",
- "API",
- "Rocket",
- "REST",
-]
-categories = [
- "web-programming",
-]
-license = "BSD-2-Clause"
-repository = "https://devcentral.nasqueron.org/source/limiting-factor/"
-
-[dependencies]
-diesel = { version = "^1.4.8", features = ["postgres", "r2d2", "chrono"], optional = true }
-dotenv = "^0.15.0"
-log = "^0.4.14"
-r2d2 = { version = "^0.8.10", optional = true }
-rocket = "^0.4.11"
-rocket_contrib = { version = "^0.4.11", features = [ "json" ] }
-serde = { version = "^1.0.159", features = [ "derive" ], optional = true }
-
-[features]
-default = ["minimal"]
-
-minimal = ["serialization"]
-full = ["pgsql", "serialization"]
-
-pgsql = ["diesel", "r2d2"]
-serialization = ["serde"]
diff --git a/Jenkinsfile b/Jenkinsfile
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -4,14 +4,18 @@
}
try {
+ stage('Toolchain') {
+ sh 'rustup override set nightly-2024-12-15'
+ }
+
stage('Build') {
- sh 'cargo build'
+ sh 'cd rocket-legacy && cargo build'
}
stage('Doc') {
- sh 'cargo doc --no-deps'
+ sh 'cd rocket-legacy && cargo doc --no-deps'
}
} finally {
- archiveArtifacts artifacts: 'target/doc/**', onlyIfSuccessful: true
+ archiveArtifacts artifacts: 'rocket-legacy/target/doc/**', onlyIfSuccessful: true
}
}
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -4,21 +4,49 @@
The goal of this library is to provide:
- - glue code for Rocket and Diesel
- standard API replies
- boilerplate to parse environment to extract configuration and run a server
+ - glue code for database support
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
+The library core features rely on:
+ * Chrono for date and time types
+ * Serde for serialization
+
+If you need PostgreSQL support:
+ * Diesel as ROM
+ * r2d2 to pool connections
+
+## Pick your crate
+
+Currently, we provide and support only `limiting-factor` crate for Rocket 0.4.
+
+We're also working on a new crate to ease migration from Rocket to Axum.
+
+The exact crate to use depends on your framework:
+
+| Framework | Crate name | To build with |
+|----------------|---------------------------------|--------------------------|
+| Axum | limiting-factor-axum | stable or nightly |
+| Rocket 0.3 | limiting-factor v0.5.1 | (1) |
+| Rocket 0.4 | limiting-factor v0.8.0 | nightly-2024-12-15 |
+| Rocket 0.5 | - | *not yet supported.* |
+
+(1) Build of Rocket 0.3 seems to be tricky and require custom dependencies:
+rocket v0.3.16 or v0.3.17 -> cookie v0.9.1 -> ring v0.11.0, a yanked crate
## Compile
+### Nightly for Rocket builds
+
+If you want to target Rocket before 0.5, you need a nightly toolchain.
+
+Stable toolchain will work for other crates.
+
### Windows
You need to give to `rustc` some hints about where `libpq.lib` is.
@@ -34,6 +62,9 @@
```
## Credits
+### Rocket x Diesel glue code
+
+The glue code to use Rocket with Diesel is adapted from Rocket v0.3 guide.
+See https://rocket.rs/guide/v0.3/state/#databases.
-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.
+Guide author: Sergio Benitez.
diff --git a/Cargo.toml b/rocket-legacy/Cargo.toml
copy from Cargo.toml
copy to rocket-legacy/Cargo.toml
--- a/Cargo.toml
+++ b/rocket-legacy/Cargo.toml
@@ -17,6 +17,7 @@
]
license = "BSD-2-Clause"
repository = "https://devcentral.nasqueron.org/source/limiting-factor/"
+edition = "2015"
[dependencies]
diesel = { version = "^1.4.8", features = ["postgres", "r2d2", "chrono"], optional = true }
diff --git a/rocket-legacy/README.md b/rocket-legacy/README.md
new file mode 100644
--- /dev/null
+++ b/rocket-legacy/README.md
@@ -0,0 +1,23 @@
+## Limiting Factor for Rocket 0.3 and 0.4
+
+### Scope
+This is the original `limiting-factor` crate.
+
+Limiting Factor has first been designed for Rocket 0.3.
+That version didn't include any database support,
+so we wanted to include it as into a helper library.
+
+Afterwards, we've found convenient to add for API:
+ - save boilerplate code to initialize the framework
+ - handle responses
+ - convert anything into JSON responses
+
+### Build
+
+The last version known to be able to build Rocket 0.4 has been identified
+by dichotomic search to be rustc 1.85.0-nightly (0aeaa5eb2 2024-12-14).
+
+You can install and use it with:
+
+ rustup install nightly-2024-12-15
+ rustup override set nightly-2024-12-15
diff --git a/src/api/guards.rs b/rocket-legacy/src/api/guards.rs
rename from src/api/guards.rs
rename to rocket-legacy/src/api/guards.rs
diff --git a/src/api/mod.rs b/rocket-legacy/src/api/mod.rs
rename from src/api/mod.rs
rename to rocket-legacy/src/api/mod.rs
diff --git a/src/api/replies.rs b/rocket-legacy/src/api/replies.rs
rename from src/api/replies.rs
rename to rocket-legacy/src/api/replies.rs
diff --git a/src/config.rs b/rocket-legacy/src/config.rs
rename from src/config.rs
rename to rocket-legacy/src/config.rs
diff --git a/src/database.rs b/rocket-legacy/src/database.rs
rename from src/database.rs
rename to rocket-legacy/src/database.rs
diff --git a/src/kernel.rs b/rocket-legacy/src/kernel.rs
rename from src/kernel.rs
rename to rocket-legacy/src/kernel.rs
diff --git a/src/lib.rs b/rocket-legacy/src/lib.rs
rename from src/lib.rs
rename to rocket-legacy/src/lib.rs

File Metadata

Mime Type
text/plain
Expires
Fri, Sep 26, 00:37 (20 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3015026
Default Alt Text
D3713.diff (6 KB)

Event Timeline