Simple Rust Pastebin example as explained in the Rocket Guide. https://rocket.rs/v0.4/guide/pastebin/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Bauke baa0f84433
Move to self-hosted Gitea, update dependencies and clean up code.
1 week ago
source Move to self-hosted Gitea, update dependencies and clean up code. 1 week ago
.gitignore Move to self-hosted Gitea, update dependencies and clean up code. 1 week ago
Cargo.lock Move to self-hosted Gitea, update dependencies and clean up code. 1 week ago
Cargo.toml Move to self-hosted Gitea, update dependencies and clean up code. 1 week ago
LICENSE Move to self-hosted Gitea, update dependencies and clean up code. 1 week ago
README.md Move to self-hosted Gitea, update dependencies and clean up code. 1 week ago
Rocket Example.toml Move to self-hosted Gitea, update dependencies and clean up code. 1 week ago
rust-toolchain Move to self-hosted Gitea, update dependencies and clean up code. 1 week ago
rustfmt.toml Move to self-hosted Gitea, update dependencies and clean up code. 1 week ago

README.md

Pastebin

Simple Rust Pastebin example as explained in the Rocket Guide.

Rocket Configuration

Copy Rocket Example.toml over to Rocket.toml and generate a secret key and TLS certificates.

cp 'Rocket Example.toml' 'Rocket.toml'

Secret Key

Generate a secret key for Rocket.toml.

openssl rand -base64 32

TLS

Generate a self-signed certificate for development.

mkdir certs/ &&
yes "" | openssl req -new -newkey rsa:4096 -x509 -sha256 -days 365 -nodes -out certs/certs.pem -keyout certs/key.pem

Or remove the TLS feature from Rocket in Cargo.toml, if you don’t want HTTPS.

Usage

Assuming you have the server setup at localhost:8000 and are using self-signed certificates.

Index

curl --insecure https://localhost:8000

Create New Paste

echo "New paste\!" | curl --insecure -X POST --data-binary @- https://localhost:8000

List All Pastes

curl --insecure https://localhost:8000/list

Show Paste

curl --insecure https://localhost:8000/<id>

Delete Paste

curl --insecure -X DELETE https://localhost:8000/<id>

License

Open-sourced under the Unlicense.