Simple Rust Pastebin example as explained in the Rocket Guide. https://rocket.rs/v0.4/guide/pastebin/
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
To repozytorium jest zarchiwizowane. Możesz wyświetlać pliki i je sklonować, ale nie możesz do niego przepychać zmian lub otwierać zgłoszeń/Pull Requestów.
Bauke baa0f84433
Move to self-hosted Gitea, update dependencies and clean up code.
1 rok temu
source Move to self-hosted Gitea, update dependencies and clean up code. 1 rok temu
.gitignore Move to self-hosted Gitea, update dependencies and clean up code. 1 rok temu
Cargo.lock Move to self-hosted Gitea, update dependencies and clean up code. 1 rok temu
Cargo.toml Move to self-hosted Gitea, update dependencies and clean up code. 1 rok temu
LICENSE Move to self-hosted Gitea, update dependencies and clean up code. 1 rok temu
README.md Move to self-hosted Gitea, update dependencies and clean up code. 1 rok temu
Rocket Example.toml Move to self-hosted Gitea, update dependencies and clean up code. 1 rok temu
rust-toolchain Move to self-hosted Gitea, update dependencies and clean up code. 1 rok temu
rustfmt.toml Move to self-hosted Gitea, update dependencies and clean up code. 1 rok temu

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.