Rocket rust example (#50)

This commit is contained in:
Jake Runzer
2021-02-04 18:49:58 -07:00
committed by GitHub
parent 39a79d19e8
commit 702523e4db
7 changed files with 94 additions and 1 deletions

View File

@@ -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",

14
examples/rocket/.gitignore vendored Normal file
View File

@@ -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

View File

@@ -0,0 +1,10 @@
[package]
name = "rocket"
version = "0.1.0"
authors = ["Jake Runzer <jakerunzer@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rocket = "0.4.6"

View File

@@ -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

19
examples/rocket/README.md Normal file
View File

@@ -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`.

View File

@@ -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();
}

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB