forked from rwf2/Rocket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.toml
201 lines (174 loc) · 6.14 KB
/
index.toml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
###############################################################################
# Release info: displayed between bars in the header
###############################################################################
[release]
version = "0.5.0-rc.3"
date = "Mar 23, 2023"
###############################################################################
# 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"
url = "overview/#how-rocket-works"
[[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"
url = "overview/#anatomy-of-a-rocket-application"
[[top_features]]
title = "Easy To Use"
text = "Simple, intuitive APIs make Rocket approachable, no matter your background."
image = "sun"
button = "Get Started"
url = "guide"
margin = 2
[[top_features]]
title = "Extensible"
text = "Create your own first-class primitives that any Rocket application can use."
image = "telescope"
button = "See How"
url = "overview/#anatomy-of-a-rocket-application"
margin = 9
###############################################################################
# Sections: make sure there are an odd number so colors work out.
###############################################################################
[[sections]]
title = "Hello, Rocket!"
code = '''
#[macro_use] extern crate rocket;
#[get("/hello/<name>/<age>")]
fn hello(name: &str, age: u8) -> String {
format!("Hello, {} year old named {}!", age, name)
}
#[launch]
fn rocket() -> _ {
rocket::build().mount("/", routes![hello])
}
'''
text = '''
This is a **complete Rocket application**. It does exactly what you would
expect. If you were to visit **/hello/John/58**, you’d see:
<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)]
struct Task<'r> {
#[field(validate = len(1..))]
description: &'r str,
completed: bool
}
#[post("/", data = "<task>")]
fn new(task: Form<Task<'_>>) -> Flash<Redirect> {
Flash::success(Redirect::to(uri!(home)), "Task added.")
}
'''
text = '''
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).
'''
[[sections]]
title = "JSON, out of the box."
code = '''
#[derive(Serialize, Deserialize)]
struct Message<'r> {
contents: &'r str,
}
#[put("/<id>", data = "<msg>")]
fn update(db: &Db, id: Id, msg: Json<Message<'_>>) -> Value {
if db.contains_key(&id) {
db.insert(id, msg.contents);
json!({ "status": "ok" })
} else {
json!({ "status": "error" })
}
}
'''
text = '''
Rocket has first-class support for JSON, right out of the box. Simply derive
`Deserialize` or `Serialize` to receive or return JSON, respectively.
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!
'''
###############################################################################
# Bottom features: displayed above the footer.
###############################################################################
[[bottom_features]]
title = 'Templating'
text = "Rocket makes templating a breeze with built-in templating support."
image = 'templating-icon'
url = 'guide/responses/#templates'
button = 'Learn More'
color = 'blue'
[[bottom_features]]
title = 'Cookies'
text = "View, add, or remove cookies, with or without encryption, without hassle."
image = 'cookies-icon'
url = 'guide/requests/#cookies'
button = 'Learn More'
color = 'purple'
margin = -6
[[bottom_features]]
title = 'Async Streams'
text = "Create and return potentially infinite async streams of data with ease."
image = 'streams-icon'
url = 'guide/responses/#async-streams'
button = 'Learn More'
color = 'red'
margin = -29
[[bottom_features]]
title = 'Config Profiles'
text = "Configure your application your way for debug, release, or anything else!"
image = 'config-icon'
url = 'guide/configuration/#profiles'
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'
url = 'guide/testing#testing'
button = 'Learn More'
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'
color = 'green'
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
# [[bottom_features]]
# title = 'Private Cookies'
# text = "Safe, secure, private cookies are built-in so your users can stay safe."
# image = 'sessions-icon'
# url = 'guide/requests/#private-cookies'
# button = 'Learn More'
# color = 'purple'