Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST request to root URL #19

Open
lus opened this issue Jul 24, 2021 · 3 comments
Open

POST request to root URL #19

lus opened this issue Jul 24, 2021 · 3 comments

Comments

@lus
Copy link
Owner

lus commented Jul 24, 2021

Maybe it would be nice to be able to create a paste by just sending a POST request to the root URL (i.e. https://pasty.lus.pm) with the request body representing the raw paste content.
This endpoint should only return the raw paste ID or URL; no JSON involved.
This would be nice for CLI users.

@zekroTJA
Copy link
Contributor

Nice Idea, but why no JSON involved? I mean, you can always use jq for that stuff:

curl -Ls -X POST https://pasty.lus.pm -d @snippet.txt | jq .id

That allows users to use further information like the deletion token. But yeah, than you can also just use the /pastes endpoint in your script if you really want, I guess. ^^

@lus
Copy link
Owner Author

lus commented Jul 27, 2021

Yeah, I am also quite unsure about that. It would be just another endpoint to implement and we would end up with 4 different ways of creating endpoints (root URL, hastebin support, API v1 ad API v2). Maybe it's not even that reasonable.

@zekroTJA
Copy link
Contributor

Another approach would be to use the Accept header. So if you specify application/json as Accept header value, you get a fully hydrated JSON response. Otherwise, if you do not specify any Accept header or if you pass text/plain, you simply get a Paste URL or ID like you originally supposed. Which one of these is set as default is up to you, but should not differ across the whole API in my opinion in order to maintain consistency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants