Write a REST API with Actix capable of performing CRUD operations on the file system using actix-web
and futures
.
This approach is taken due to interest on understanding Rust Futures and getting to know the API better, current Actix
versions make use of the actix-web-rt
. Instead this version relies on futures
to accomplish asynchronous programming.
The idea is inspired on the file_transfer
project explained in "Creative Projects for Rust Programmers" by Carlo Milanesi,
but as the project evolved major changes were made in order to experiment other Rust features which are out of the scope
of the book.
# clone the repository
git clone https://github.com/EstebanBorai/simple-file-transfer-server.git
# step into project directory
cd ./simple-file-transfer-server
# run with cargo
cargo run
Every filesystem operation will run in the included
archive
directory, if a request is send as/hello_world.txt
then the path to the file in question will be$PWD/archive/hello_world.txt
.
Method | URI | Description | Req. Body | Res. Body |
---|---|---|---|---|
GET | /:filename |
Reads the file specified in the path | N/A | String |
POST | /:filename |
Creates a new file with the contents of the request body | String |
String |
PUT | /:filename |
Overwrites a file with the contents of the request body | String |
String |
DELETE | /:filename |
Removes the file specified in the path | N/A | N/A |
Any contribution to this project is welcome, as pointed out above this project is inspired by a book example but some changes where made to acomplish an universal usage and also to experiment other features which are out of the scope of the book examples.
Licensed under the GNU General Public License