style(server): make the default landing page fancier

This commit is contained in:
Orhun Parmaksız 2023-05-14 01:54:58 +03:00
parent 607f07b6e1
commit 4a4301ee72
No known key found for this signature in database
GPG key ID: F83424824B3E4B90
2 changed files with 16 additions and 7 deletions

View file

@ -8,9 +8,14 @@ max_content_length = "10MB"
upload_path = "./upload" upload_path = "./upload"
timeout = "30s" timeout = "30s"
expose_version = false expose_version = false
landing_page = """Submit files via HTTP POST here: landing_page = """
curl -F 'file=@example.txt' <server>"
This will return the finished URL.
Submit files via HTTP POST here:
curl -F 'file=@example.txt' <server>
This will return the URL of the uploaded file.
The server administrator might remove any pastes that they do not personally The server administrator might remove any pastes that they do not personally
want to host. want to host.
@ -19,10 +24,12 @@ If you are the server administrator and want to change this page, just go
into your config file and change it! If you change the expiry time, it is into your config file and change it! If you change the expiry time, it is
recommended that you do. recommended that you do.
Check out the GitHub repository at https://github.com/orhun/rustypaste
By default, pastes expire every hour. The server admin may or may not have By default, pastes expire every hour. The server admin may or may not have
changed this.""" changed this.
Check out the GitHub repository at https://github.com/orhun/rustypaste
Command line tool is available at https://github.com/orhun/rustypaste-cli
"""
[paste] [paste]
random_url = { enabled = true, type = "petname", words = 2, separator = "-" } random_url = { enabled = true, type = "petname", words = 2, separator = "-" }

View file

@ -25,7 +25,9 @@ async fn index(config: web::Data<RwLock<Config>>) -> Result<HttpResponse, Error>
.read() .read()
.map_err(|_| error::ErrorInternalServerError("cannot acquire config"))?; .map_err(|_| error::ErrorInternalServerError("cannot acquire config"))?;
match &config.server.landing_page { match &config.server.landing_page {
Some(page) => Ok(HttpResponse::Ok().body(page.clone())), Some(page) => Ok(HttpResponse::Ok()
.content_type("text/plain; charset=\"UTF-8\"")
.body(page.clone())),
None => Ok(HttpResponse::Found() None => Ok(HttpResponse::Found()
.append_header(("Location", env!("CARGO_PKG_HOMEPAGE"))) .append_header(("Location", env!("CARGO_PKG_HOMEPAGE")))
.finish()), .finish()),