2018-10-29 03:12:46 +00:00
|
|
|
|
###############################################################################
|
|
|
|
|
# Release info: displayed between bars in the header
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
[release]
|
2023-11-02 00:18:11 +00:00
|
|
|
|
version = "0.5.0-rc.4"
|
|
|
|
|
date = "Nov 1, 2023"
|
2018-10-29 03:12:46 +00:00
|
|
|
|
|
2017-04-17 02:48:59 +00:00
|
|
|
|
###############################################################################
|
|
|
|
|
# Top features: displayed in the header under the introductory text.
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
[[top_features]]
|
|
|
|
|
title = "Type Safe"
|
|
|
|
|
text = "From request to response Rocket ensures that your types mean something."
|
|
|
|
|
image = "helmet"
|
|
|
|
|
button = "Learn More"
|
2018-10-16 05:50:35 +00:00
|
|
|
|
url = "overview/#how-rocket-works"
|
2017-04-17 02:48:59 +00:00
|
|
|
|
|
|
|
|
|
[[top_features]]
|
|
|
|
|
title = "Boilerplate Free"
|
|
|
|
|
text = "Spend your time writing code that really matters, and let Rocket generate the rest."
|
|
|
|
|
image = "robot-free"
|
|
|
|
|
button = "See Examples"
|
2018-10-16 05:50:35 +00:00
|
|
|
|
url = "overview/#anatomy-of-a-rocket-application"
|
2017-04-17 02:48:59 +00:00
|
|
|
|
|
|
|
|
|
[[top_features]]
|
|
|
|
|
title = "Easy To Use"
|
2018-10-26 10:32:50 +00:00
|
|
|
|
text = "Simple, intuitive APIs make Rocket approachable, no matter your background."
|
2017-04-17 02:48:59 +00:00
|
|
|
|
image = "sun"
|
|
|
|
|
button = "Get Started"
|
2018-10-16 05:50:35 +00:00
|
|
|
|
url = "guide"
|
2017-04-17 02:48:59 +00:00
|
|
|
|
margin = 2
|
|
|
|
|
|
|
|
|
|
[[top_features]]
|
|
|
|
|
title = "Extensible"
|
2018-10-26 10:32:50 +00:00
|
|
|
|
text = "Create your own first-class primitives that any Rocket application can use."
|
2017-04-17 02:48:59 +00:00
|
|
|
|
image = "telescope"
|
|
|
|
|
button = "See How"
|
2018-10-16 05:50:35 +00:00
|
|
|
|
url = "overview/#anatomy-of-a-rocket-application"
|
2017-04-17 02:48:59 +00:00
|
|
|
|
margin = 9
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
|
# Sections: make sure there are an odd number so colors work out.
|
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
[[sections]]
|
|
|
|
|
title = "Hello, Rocket!"
|
|
|
|
|
code = '''
|
2018-10-05 04:44:42 +00:00
|
|
|
|
#[macro_use] extern crate rocket;
|
2017-04-17 02:48:59 +00:00
|
|
|
|
|
|
|
|
|
#[get("/hello/<name>/<age>")]
|
2021-03-27 23:25:39 +00:00
|
|
|
|
fn hello(name: &str, age: u8) -> String {
|
2017-04-17 02:48:59 +00:00
|
|
|
|
format!("Hello, {} year old named {}!", age, name)
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-16 12:01:26 +00:00
|
|
|
|
#[launch]
|
2021-04-14 04:59:11 +00:00
|
|
|
|
fn rocket() -> _ {
|
2021-04-08 08:07:52 +00:00
|
|
|
|
rocket::build().mount("/", routes![hello])
|
2017-04-17 02:48:59 +00:00
|
|
|
|
}
|
|
|
|
|
'''
|
|
|
|
|
text = '''
|
|
|
|
|
This is a **complete Rocket application**. It does exactly what you would
|
2021-06-27 00:10:57 +00:00
|
|
|
|
expect. If you were to visit **/hello/John/58**, you’d see:
|
2017-04-17 02:48:59 +00:00
|
|
|
|
|
|
|
|
|
<span class="callout">Hello, 58 year old named John!</span>
|
|
|
|
|
|
|
|
|
|
If someone visits a path with an `<age>` that isn’t a `u8`, Rocket doesn’t
|
|
|
|
|
blindly call `hello`. Instead, it tries other matching routes or returns a
|
|
|
|
|
**404**.
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
[[sections]]
|
|
|
|
|
title = "Forms? Check!"
|
|
|
|
|
code = '''
|
|
|
|
|
#[derive(FromForm)]
|
2021-03-27 23:25:39 +00:00
|
|
|
|
struct Task<'r> {
|
2021-06-27 00:10:57 +00:00
|
|
|
|
#[field(validate = len(1..))]
|
2021-03-27 23:25:39 +00:00
|
|
|
|
description: &'r str,
|
2017-04-17 02:48:59 +00:00
|
|
|
|
completed: bool
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[post("/", data = "<task>")]
|
2021-03-27 23:25:39 +00:00
|
|
|
|
fn new(task: Form<Task<'_>>) -> Flash<Redirect> {
|
2021-06-27 00:10:57 +00:00
|
|
|
|
Flash::success(Redirect::to(uri!(home)), "Task added.")
|
2017-04-17 02:48:59 +00:00
|
|
|
|
}
|
|
|
|
|
'''
|
|
|
|
|
text = '''
|
2021-06-27 00:10:57 +00:00
|
|
|
|
Form handling **is simple, declarative, and complete**: derive
|
|
|
|
|
[`FromForm`](@api/rocket/derive.FromForm.html) for your structure and set the
|
|
|
|
|
`data` parameter to a `Form` type. Rocket automatically **parses and
|
|
|
|
|
validates** the form data into your structure and calls your function.
|
|
|
|
|
|
|
|
|
|
Bad form request? Rocket doesn’t call your function! Need to know what went
|
|
|
|
|
wrong? Use a `data` parameter of `Result`! Want to rerender the form with user
|
|
|
|
|
input and errors? Use [`Context`](guide/requests/#context)! File uploads? A
|
|
|
|
|
breeze with [`TempFile`](@api/rocket/fs/enum.TempFile.html).
|
2017-04-17 02:48:59 +00:00
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
[[sections]]
|
|
|
|
|
title = "JSON, out of the box."
|
|
|
|
|
code = '''
|
|
|
|
|
#[derive(Serialize, Deserialize)]
|
2021-03-27 23:25:39 +00:00
|
|
|
|
struct Message<'r> {
|
|
|
|
|
contents: &'r str,
|
2017-04-17 02:48:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-26 10:32:50 +00:00
|
|
|
|
#[put("/<id>", data = "<msg>")]
|
2021-06-27 00:10:57 +00:00
|
|
|
|
fn update(db: &Db, id: Id, msg: Json<Message<'_>>) -> Value {
|
2018-10-22 21:47:35 +00:00
|
|
|
|
if db.contains_key(&id) {
|
2021-03-27 23:25:39 +00:00
|
|
|
|
db.insert(id, msg.contents);
|
2017-08-26 06:14:42 +00:00
|
|
|
|
json!({ "status": "ok" })
|
2017-04-17 02:48:59 +00:00
|
|
|
|
} else {
|
2017-08-26 06:14:42 +00:00
|
|
|
|
json!({ "status": "error" })
|
2017-04-17 02:48:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
'''
|
|
|
|
|
text = '''
|
|
|
|
|
Rocket has first-class support for JSON, right out of the box. Simply derive
|
|
|
|
|
`Deserialize` or `Serialize` to receive or return JSON, respectively.
|
|
|
|
|
|
2021-06-27 00:10:57 +00:00
|
|
|
|
Look familiar? Forms, JSON, and all kinds of body data types work through
|
|
|
|
|
Rocket’s [`FromData`](@api/rocket/data/trait.FromData.html) trait, Rocket’s
|
|
|
|
|
approach to deriving types from body data. A `data` route parameter can be
|
|
|
|
|
_any_ type that implements `FromData`. A value of that type will be
|
|
|
|
|
deserialized automatically from the incoming request body. You can even
|
|
|
|
|
implement `FromData` for your own types!
|
2017-04-17 02:48:59 +00:00
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
2022-09-07 12:42:21 +00:00
|
|
|
|
# Bottom features: displayed above the footer.
|
2017-04-17 02:48:59 +00:00
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
|
|
[[bottom_features]]
|
|
|
|
|
title = 'Templating'
|
2018-10-22 21:47:35 +00:00
|
|
|
|
text = "Rocket makes templating a breeze with built-in templating support."
|
2017-04-17 02:48:59 +00:00
|
|
|
|
image = 'templating-icon'
|
2018-10-16 05:50:35 +00:00
|
|
|
|
url = 'guide/responses/#templates'
|
2017-04-17 02:48:59 +00:00
|
|
|
|
button = 'Learn More'
|
|
|
|
|
color = 'blue'
|
|
|
|
|
|
|
|
|
|
[[bottom_features]]
|
|
|
|
|
title = 'Cookies'
|
2017-07-10 11:59:55 +00:00
|
|
|
|
text = "View, add, or remove cookies, with or without encryption, without hassle."
|
2017-04-17 02:48:59 +00:00
|
|
|
|
image = 'cookies-icon'
|
2018-10-16 05:50:35 +00:00
|
|
|
|
url = 'guide/requests/#cookies'
|
2017-04-17 02:48:59 +00:00
|
|
|
|
button = 'Learn More'
|
|
|
|
|
color = 'purple'
|
|
|
|
|
margin = -6
|
|
|
|
|
|
|
|
|
|
[[bottom_features]]
|
2021-06-09 09:53:11 +00:00
|
|
|
|
title = 'Async Streams'
|
|
|
|
|
text = "Create and return potentially infinite async streams of data with ease."
|
2017-04-17 02:48:59 +00:00
|
|
|
|
image = 'streams-icon'
|
2021-06-09 09:53:11 +00:00
|
|
|
|
url = 'guide/responses/#async-streams'
|
2017-04-17 02:48:59 +00:00
|
|
|
|
button = 'Learn More'
|
|
|
|
|
color = 'red'
|
|
|
|
|
margin = -29
|
|
|
|
|
|
|
|
|
|
[[bottom_features]]
|
2021-06-09 09:53:11 +00:00
|
|
|
|
title = 'Config Profiles'
|
|
|
|
|
text = "Configure your application your way for debug, release, or anything else!"
|
2017-04-17 02:48:59 +00:00
|
|
|
|
image = 'config-icon'
|
2021-06-09 09:53:11 +00:00
|
|
|
|
url = 'guide/configuration/#profiles'
|
2017-04-17 02:48:59 +00:00
|
|
|
|
button = 'Learn More'
|
|
|
|
|
color = 'yellow'
|
|
|
|
|
margin = -3
|
|
|
|
|
|
|
|
|
|
[[bottom_features]]
|
|
|
|
|
title = 'Testing Library'
|
|
|
|
|
text = "Unit test your applications with ease using the built-in testing library."
|
|
|
|
|
image = 'testing-icon'
|
2018-10-16 05:50:35 +00:00
|
|
|
|
url = 'guide/testing#testing'
|
2017-04-17 02:48:59 +00:00
|
|
|
|
button = 'Learn More'
|
2018-10-22 21:47:35 +00:00
|
|
|
|
color = 'orange'
|
|
|
|
|
|
|
|
|
|
[[bottom_features]]
|
|
|
|
|
title = 'Typed URIs'
|
|
|
|
|
text = "Rocket typechecks route URIs for you so you never mistype a URI again."
|
|
|
|
|
image = 'ship-icon'
|
|
|
|
|
url = 'guide/responses/#typed-uris'
|
|
|
|
|
button = 'Learn More'
|
2017-04-17 02:48:59 +00:00
|
|
|
|
color = 'green'
|
2018-10-22 21:47:35 +00:00
|
|
|
|
margin = -20
|
|
|
|
|
|
|
|
|
|
# [[bottom_features]]
|
|
|
|
|
# title = 'Query Strings'
|
|
|
|
|
# text = "Handling query strings and parameters is type-safe and easy in Rocket."
|
|
|
|
|
# image = 'query-icon'
|
|
|
|
|
# url = 'guide/requests/#query-strings'
|
|
|
|
|
# button = 'Learn More'
|
|
|
|
|
# color = 'red'
|
|
|
|
|
# margin = -3
|
2017-04-17 02:48:59 +00:00
|
|
|
|
|
|
|
|
|
# [[bottom_features]]
|
2018-10-22 21:47:35 +00:00
|
|
|
|
# title = 'Private Cookies'
|
|
|
|
|
# text = "Safe, secure, private cookies are built-in so your users can stay safe."
|
2017-04-17 02:48:59 +00:00
|
|
|
|
# image = 'sessions-icon'
|
2018-10-22 21:47:35 +00:00
|
|
|
|
# url = 'guide/requests/#private-cookies'
|
2017-04-17 02:48:59 +00:00
|
|
|
|
# button = 'Learn More'
|
2018-10-22 21:47:35 +00:00
|
|
|
|
# color = 'purple'
|