diff --git a/examples.json b/examples.json index 1bf5555..9d622b8 100644 --- a/examples.json +++ b/examples.json @@ -40,6 +40,14 @@ { "name": "DISCORD_TOKEN", "desc": "Token of the Discord account used" } ] }, + { + "text": "Rocket", + "value": "rocket-rust", + "desc": "Fast webserver written in Rust", + "href": "https://github.com/railwayapp/examples/tree/master/examples/rocket", + "icon": "rust.svg", + "tags": ["rust"] + }, { "text": "Rails Starter", "value": "rails-starter", diff --git a/examples/rocket/.gitignore b/examples/rocket/.gitignore new file mode 100644 index 0000000..4bb7fbc --- /dev/null +++ b/examples/rocket/.gitignore @@ -0,0 +1,14 @@ +# Created by https://www.toptal.com/developers/gitignore/api/rust +# Edit at https://www.toptal.com/developers/gitignore?templates=rust + +### Rust ### +# Generated by Cargo +# will have compiled files and executables +/target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# End of https://www.toptal.com/developers/gitignore/api/rust + diff --git a/examples/rocket/Cargo.toml b/examples/rocket/Cargo.toml new file mode 100644 index 0000000..de81f7b --- /dev/null +++ b/examples/rocket/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "rocket" +version = "0.1.0" +authors = ["Jake Runzer "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +rocket = "0.4.6" diff --git a/examples/rocket/Dockerfile b/examples/rocket/Dockerfile new file mode 100644 index 0000000..27bc2ef --- /dev/null +++ b/examples/rocket/Dockerfile @@ -0,0 +1,13 @@ +FROM rustlang/rust:nightly + +ARG PORT + +ENV ROCKET_ADDRESS=0.0.0.0 +ENV ROCKET_ENV=staging + +WORKDIR /app +COPY . . + +RUN cargo build + +CMD ROCKET_PORT=$PORT cargo run diff --git a/examples/rocket/README.md b/examples/rocket/README.md new file mode 100644 index 0000000..f16540f --- /dev/null +++ b/examples/rocket/README.md @@ -0,0 +1,19 @@ +# Rust Rocket Example + +This example is a [Rocket](https://rocket.rs) web server + +[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new?template=https%3A%2F%2Fgithub.com%2Frailwayapp%2Fexamples%2Ftree%2Fmaster%2Fexamples%2Frocket) + +## ✨ Features + +- Rust +- Rocket + +## 💁‍♀️ How to use + +- Run the server `cargo run` + +## 📝 Notes + +By default, the Rocket server is started in staging mode. You can start in +production mode by changing `ROCKET_ENV` in the `Dockerfile`. diff --git a/examples/rocket/src/main.rs b/examples/rocket/src/main.rs new file mode 100644 index 0000000..40e5be5 --- /dev/null +++ b/examples/rocket/src/main.rs @@ -0,0 +1,12 @@ +#![feature(proc_macro_hygiene, decl_macro)] + +#[macro_use] extern crate rocket; + +#[get("/")] +fn index() -> &'static str { + "Choo Choo! Welcome to your Rocket server 🚅" +} + +fn main() { + rocket::ignite().mount("/", routes![index]).launch(); +} diff --git a/icons/rust.svg b/icons/rust.svg index cba4303..fd5c02e 100644 --- a/icons/rust.svg +++ b/icons/rust.svg @@ -1 +1,18 @@ - \ No newline at end of file + + \ No newline at end of file