mirror of
https://github.com/SrIzan10/starters.git
synced 2026-05-01 11:05:16 +00:00
Rocket rust example (#50)
This commit is contained in:
@@ -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
14
examples/rocket/.gitignore
vendored
Normal 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
|
||||
|
||||
10
examples/rocket/Cargo.toml
Normal file
10
examples/rocket/Cargo.toml
Normal 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"
|
||||
13
examples/rocket/Dockerfile
Normal file
13
examples/rocket/Dockerfile
Normal 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
19
examples/rocket/README.md
Normal file
@@ -0,0 +1,19 @@
|
||||
# Rust Rocket Example
|
||||
|
||||
This example is a [Rocket](https://rocket.rs) web server
|
||||
|
||||
[](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`.
|
||||
12
examples/rocket/src/main.rs
Normal file
12
examples/rocket/src/main.rs
Normal 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 |
Reference in New Issue
Block a user