Skip to content

Commit edcdf0a

Browse files
committed
Split insertion routes for form an JSON API
1 parent f182bca commit edcdf0a

File tree

7 files changed

+313
-350
lines changed

7 files changed

+313
-350
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
- **Breaking**: Always return HTML on `/:id` even if `text/html` is not in the
1616
Accept header. On the other hand, `/raw/:id` must be used to retrieve raw
1717
text.
18+
- **Breaking**: `POST`ing new entries via the JSON API now have to go via the
19+
`/api` root endpoint.
1820
- Use the [two-face](https://docs.rs/two-face) crate for an extended syntax
1921
list.
2022
- Serve all CSS assets under hashed URL to avoid caching issues.

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,16 @@ run-time behavior:
152152

153153
### API endpoints
154154

155-
POST a new paste to the `/` endpoint with the following JSON payload:
155+
POST a new paste to the `/api` endpoint with the following JSON payload:
156156

157157
```
158158
{
159159
"text": "<paste content>",
160160
"extension": "<file extension, optional>",
161+
"title": "<paste title, optional>",
161162
"expires": <number of seconds from now, optional>,
162-
"burn_after_reading": <true/false, optional>
163+
"burn_after_reading": <true/false, optional>,
164+
"password": <password for encryption optional>,
163165
}
164166
```
165167

@@ -194,7 +196,7 @@ line using `xclip`, `curl` and `jq`. Define the following function in your
194196
function paste_from_clipboard() {
195197
local URL=$(\
196198
jq -n --arg t "$(xclip -selection clipboard -o)" '{text: $t}' | \
197-
curl -s -H 'Content-Type: application/json' --data-binary @- https://wastebin.tld | \
199+
curl -s -H 'Content-Type: application/json' --data-binary @- https://wastebin.tld/api | \
198200
jq -r '. | "https://wastebin.tld\(.path)"')
199201

200202
xdg-open $URL
@@ -208,7 +210,7 @@ To paste from stdin use the following function in your `.bashrc`:
208210
```bash
209211
function paste_from_stdin() {
210212
jq -Rns '{text: inputs}' | \
211-
curl -s -H 'Content-Type: application/json' --data-binary @- https://wastebin.tld | \
213+
curl -s -H 'Content-Type: application/json' --data-binary @- https://wastebin.tld/api | \
212214
jq -r '. | "wastebin.tld\(.path)"'
213215
}
214216
```

src/handlers/insert.rs

Lines changed: 0 additions & 344 deletions
This file was deleted.

0 commit comments

Comments
 (0)