13 releases (6 breaking)

Uses old Rust 2015

0.17.9 Jun 3, 2018
0.17.8 Jan 25, 2018
0.15.0 Jan 19, 2018
0.9.1 Jan 18, 2018
0.1.0 Dec 16, 2017

#17 in #iron-web

50 downloads per month
Used in pastebind

MIT/Apache

38KB
582 lines

crates.io docs.rs travis-ci

Simple pastebin service

About

A simple multipurpose RESTful storage server library written in Rust with Iron web framework under the cover.

Please note! This library crate provides only a library (obviously), and a real server is decoupled into a separate crate pastebind. Usage information is provided in that crate as well.

REST api

To upload data (be it text or a file) simply send it using either a POST or a PUT request to /. You can additinally specify a file name as a URI segment, like /file.txt. The service will reply with a link that contains ID of the paste. That address should be used later to manipulate the paste.

To specify an expiry date add a query parameter expires to your POST (PUT) request with value of a desired expiration date (UTC) in the form of a unix timestamp, like the following: ?expires=1546300800 for the 1st of January, 2019 (UTC). If you don't specify the date it will be set to the server's defaults (default expiration time is passed as a command line argument to the service application). In order to make a paste to be stored without a time limit you have to pass a special value never, like the following: ?expires=never.

To download data send a GET request to /id, where id is a paste ID obtained on the previous step. Actually it's not like you don't have to specifically obtain an ID, just use the returned link from the POST (PUT) as it is. If the paste has information about its file name the service will redirect the request to /id/file-name so you'll be able to save the file under the correct name. By the way, if you want to take advantage of this feature while using wget pass --content-disposition flag to your command.

You can also optionally provide a desired file name like /id/file-name to your GET request.

To delete a paste send a DELETE request to /id, and the paste will be deleted (if it exists obviously).

Performance

To be done.

Dependencies

~21MB
~411K SLoC