- Notifications
You must be signed in to change notification settings - Fork1.6k
rwf2/Rocket
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Rocket is an async web framework for Rust with a focus on usability, security,extensibility, and speed.
#[macro_use]externcrate rocket;#[get("/<name>/<age>")]fnhello(name:&str,age:u8) ->String{format!("Hello, {} year old named {}!", age, name)}#[launch]fnrocket() ->_{ rocket::build().mount("/hello",routes![hello])}
Visitinglocalhost:8000/hello/John/58
, for example, will trigger thehello
route resulting in the stringHello, 58 year old named John!
being sent to thebrowser. If an<age>
string was passed in that can't be parsed as au8
, theroute won't get called, resulting in a 404 error.
Rocket is extensively documented:
- Overview: A brief look at what makes Rocket special.
- Quickstart: How to get started as quickly as possible.
- Getting Started: How to start your first Rocket project.
- Guide: A detailed guide and reference to Rocket.
- API Documentation: The "rustdocs".
Documentation for themaster
branch is available athttps://rocket.rs/masterandhttps://api.rocket.rs/master.
Documentation for major release version${x}
is available athttps://[api.]rocket.rs/v${x}
. For example, the v0.4 docs are available athttps://rocket.rs/v0.4 andhttps://api.rocket.rs/v0.4.
Finally, API docs for active git branches are available athttps://api.rocket.rs/${branch}
. For example, API docs for themaster
branchare available athttps://api.rocket.rs/master. Branch rustdocs are built anddeployed on every commit.
Theexamples directory contains complete crates that showcaseRocket's features and usage. Each example can be compiled and run with Cargo.For instance, the following sequence of commands builds and runs thehello
example:
cd examples/hellocargo run
If you find yourself needing help outside of the documentation, you may:
- Ask questions viaGitHub discussions questions.
- Chat with us at
#rocket:mozilla.org
on Matrix (joinvia Element).
Contributions are absolutely, positively welcomed and encouraged! If you'reinterested in contributing code, please first readCONTRIBUTING for completeguidelines. Additionally, you could:
- Submit a feature request or bug report as anissue.
- Ask for improved documentation as anissue.
- Comment onissues that require feedback.
- Answers questions inGitHub discussions questions.
- Share a project inGitHub discussions show & tell.
Rocket is licensed under either of the following, at your option:
- Apache License, Version 2.0, (LICENSE-APACHE orhttps://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT orhttps://opensource.org/licenses/MIT)
Unless you explicitly state otherwise, any contribution intentionally submittedfor inclusion in Rocket by you shall be dual licensed under the MIT License andApache License, Version 2.0, without any additional terms or conditions.
The Rocket website docs are licensed underseparate terms. Anycontribution intentionally submitted for inclusion in the Rocket website docs byyou shall be licensed under those terms.
About
A web framework for Rust.