Дамјан Георгиевски
09cba55dc8
use rust language edition 2018 (introduced in 1.31)
2018-12-06 20:08:26 +01:00
Дамјан Георгиевски
2742a39aaa
update for a change after actix-web 0.7.8
...
somewhere between 0.7.8 and 0.7.12 `web::create_app` started returning a
`Result`.
2018-10-20 15:04:13 +02:00
Дамјан Георгиевски
7a0572de80
use system alocator instead of jmalloc
...
Rust 1.28 feature. saves 300kb in executable size
2018-08-03 15:41:00 +02:00
Дамјан Георгиевски
4346b5d559
since actix-web 0.7.2 this is the default log format
2018-07-26 18:53:04 +02:00
Damjan Georgievski
306c545151
let's return a Result from create_app
...
with the possibility that any errors could be reported/handled by the
caller. the lambda in server::new(|| ...) doesn't care though
2018-07-23 00:32:59 +02:00
Damjan Georgievski
d2f9578b68
add some headers to the favicon
...
* content-type to image/png
* cache control for 24h
2018-07-22 17:45:28 +02:00
Damjan Georgievski
1aeb2c1bf6
smaller font in footer
2018-07-22 17:27:40 +02:00
Damjan Georgievski
b139b6113a
return error instead of expect()
...
expect() is an unwrap() with a message. use the ? macro to just return
the error from main for a cleaner output
2018-07-22 17:14:01 +02:00
Damjan Georgievski
bd1429ebb6
explain why these won't panic
2018-07-22 17:09:53 +02:00
Damjan Georgievski
71482ffacd
don't panic on r.metadata()
...
use unwrap_or() instead of unwrap() to avoid panics if metadata can't be
read from a direntry.
optimistic_is_dir will just return false in that case (same as non
directory)
2018-07-22 17:08:21 +02:00
Damjan Georgievski
625bbcc0b9
replace the unwrap with a error return
...
don't panic on std::fs::read_dir error (although permission errors are
returned as 404 responses)
2018-07-22 07:41:05 +02:00
Damjan Georgievski
9058452d93
set_current_dir: don't unwrap, return error
...
the difference is a panic vs a clean error
2018-07-22 07:25:07 +02:00
Damjan Georgievski
01f0001594
dark style, footer, homepage
2018-07-22 06:55:58 +02:00
Damjan Georgievski
592ea53524
many improvements to the html generated
...
- css is now in src/style.css - included in the executable at compile time
- use writeln!/write! macros instead of push_str + format!
- properly generate the link to the .tar for the current directory
v0.6
2018-07-22 05:51:55 +02:00
Damjan Georgievski
1a12b3aa30
canonicalized root directory is now also an App state
...
- used to setup the StaticFiles handler
- also for the .tar file handler
additionally, PathBuf::from_param is used to forbid certain paths, see:
https://actix.rs/api/actix-web/stable/actix_web/dev/trait.FromParam.html
2018-07-22 05:39:32 +02:00
Damjan Georgievski
8a86739f14
don't overwrite RUST_LOG if it exists
2018-07-22 03:53:39 +02:00
Damjan Georgievski
06e5cd47eb
this can be expressed in a single filter_map
2018-07-21 21:27:57 +02:00
Damjan Georgievski
a9c0e1ec81
use r#" "# string literals so to not escape the "
2018-07-21 20:27:03 +02:00
Damjan Georgievski
ac3627179f
insignificant changes
...
still experimenting with *my* rust style
2018-07-21 20:22:40 +02:00
Damjan Georgievski
a3a95e66c3
also chdir to destination directory
2018-07-21 20:13:14 +02:00
Damjan Georgievski
6ad16f8dcf
r.get() is a shortcut for r.method(Method::GET)
2018-07-21 20:01:28 +02:00
Damjan Georgievski
9373a1cb9c
upercase PORT in usage
2018-07-21 19:31:43 +02:00
Damjan Georgievski
e707d1a05e
log shared directory
2018-07-21 19:12:59 +02:00
Damjan Georgievski
0967442fcd
add a favicon
...
- fixes #6
- the image is embeded in the executable with the include_bytes! macro
- I choose a simple share image
2018-07-21 18:41:02 +02:00
Damjan Georgievski
e400d6e1d3
implement cli arguments with clap
...
* add clap dependency https://docs.rs/clap/
* updated README with the real USAGE
* the web App now takes a directory to server files from
2018-07-21 17:45:24 +02:00
Damjan Georgievski
933b53b2b1
remove the println! since the logger already prints the listener
2018-07-21 15:14:01 +02:00
Damjan Georgievski
091f203317
use a non default logger that doesn't log the timestamp
...
the env_logger already adds the timestamp, so it was redundant
before:
`INFO 2018-07-21T12:57:49Z: actix_web::middleware::logger: 127.0.0.1:42112 [21/Jul/2018:14:57:49 +0200] "GET / HTTP/1.1" 200 858 "-" "curl/7.61.0" 0.000686`
after:
`INFO 2018-07-21T13:03:20Z: actix_web::middleware::logger: 127.0.0.1:42154 "GET / HTTP/1.1" 200 858 "-" "curl/7.61.0" 0.000367`
2018-07-21 15:13:30 +02:00
Damjan Georgievski
a6a3d707d6
implement a default logger
...
I've snuck some renames of variables too
2018-07-21 14:59:47 +02:00
Дамјан Георгиевски
c91c994c8c
actix_web reexports actix
...
Re-export actix::prelude::* as actix_web::actix module.
So no need to explicitly import it or add it in Cargo.toml
2018-07-19 20:03:17 +02:00
Дамјан Георгиевски
e8d3481108
the size is not bytes but objects
...
and objects were byte arrays (typically 8KB).
limit it to 64, so typically not more than 512kb is used. doesn't change
the max speed when downloading on localhost, and decreases the RSS usage
with slow clients.
2018-07-13 09:48:42 +02:00
Дамјан Георгиевски
9a56bcb1a0
slight reorganization of the html generation
2018-07-08 16:11:19 +02:00
Дамјан Георгиевски
e9ef0d582e
insignificant changes
...
* renamed `run_tar_in_thread()` to `stream_tar_in_thread()`
* use `impl Responder` instead of `Result<HttpResponse>`
* add an `.unwrap()` to `StaticFiles::new()` (seems to be an upstream API change)
2018-07-08 16:07:32 +02:00
Дамјан Георгиевски
803ffc0c99
use futures::sync::mpsc::channel() with 4MB buffer
...
… instead of unbounded() with no limits in buffering
this should implement a back pressure, when the client can't read the
response fast enough, the thread creating the archive would block the
write, instead of filling the memory.
Use Sink::wait() to make a blocking Sender
2018-07-07 23:49:46 +02:00
Дамјан Георгиевски
62a99f8dc3
use just last part of pathname in the tar
...
Previously:
```
$ curl -s http://localhost:8000/target/release/build.tar -o - | tar tf -
target/release/build/rayon-core-b8ae11d289218da3
…
```
Now:
```
$ curl -s http://localhost:8000/target/release/build.tar -o - | tar tf -
build/rayon-core-b8ae11d289218da3
…
```
2018-07-07 23:47:35 +02:00
Дамјан Георгиевски
17a40e188a
forgot the second point
2018-07-05 17:57:12 +02:00
Дамјан Георгиевски
fd46bfb55a
refactor: split code in multiple files
...
… main.rs is now small enough to add cli args
2018-07-05 17:48:40 +02:00
Дамјан Георгиевски
b8f4607dba
fancier dir list template
2018-07-05 10:55:22 +02:00
Дамјан Георгиевски
591587649c
sort directories first, and then alphabetically by filename
2018-07-04 23:41:54 +02:00
Дамјан Георгиевски
a8fef98041
charset=utf-8
2018-07-04 23:31:02 +02:00
Дамјан Георгиевски
95adb78666
double quotes for html attribute values
2018-07-04 23:30:37 +02:00
Дамјан Георгиевски
46ffbeaa6e
implement streaming of a folder as a tar
2018-07-04 23:14:05 +02:00
Дамјан Георгиевски
b5533e1428
implement custom directory listing
2018-07-04 23:13:32 +02:00
Дамјан Георгиевски
7845a4e3d7
first skeleton
2018-07-04 14:03:30 +02:00