Backwards incompatible. API calls now need to pass all arguments via POST.

This commit is contained in:
Martin Mahner 2016-03-23 14:02:48 +01:00
parent d2a704c075
commit b046d8ab87
2 changed files with 14 additions and 15 deletions

View file

@ -20,13 +20,13 @@ The UTF-8 encoded string you want to paste.
``lexer`` (optional)
~~~~~~~~~~~~~~~~~~~~
Can also be set via GET. The lexer string key used for highlighting.
See `lexer list`_ for a full list of choices. Default: ``python``.
The lexer string key used for highlighting. See `lexer list`_ for a full list
of choices. Default: ``python``.
``format`` (optional)
~~~~~~~~~~~~~~~~~~~~~
Can also be set via GET. The format of the API response. Choices are:
The format of the API response. Choices are:
* ``default`` — Returns a full qualified URL wrapped in quotes. Example::
@ -51,10 +51,10 @@ Can also be set via GET. The format of the API response. Choices are:
``expires`` (optional)
~~~~~~~~~~~~~~~~~~~~~~
Can also be set via GET. A keyword to indicate the lifetime of a
snippetn in seconds. The values are predefined by the server. Calling this with
an invalid value returns a HTTP 400 BadRequest together with a list of valid
values. Default: ``2592000``. In the default configuration valid values are:
A keyword to indicate the lifetime of a snippetn in seconds. The values are
predefined by the server. Calling this with an invalid value returns a HTTP 400
BadRequest together with a list of valid values. Default: ``2592000``. In the
default configuration valid values are:
* onetime
* never
@ -65,10 +65,9 @@ values. Default: ``2592000``. In the default configuration valid values are:
``filename`` (optional)
~~~~~~~~~~~~~~~~~~~~~~~
Can also be set via GET. A filename which we use to determine a lexer, if
``lexer`` is not set. In case we can't determine a file, the lexer will fallback
to ``plain`` code (no highlighting). A given ``lexer`` will overwrite any
filename! Example::
A filename which we use to determine a lexer, if ``lexer`` is not set. In case
we can't determine a file, the lexer will fallback to ``plain`` code (no
highlighting). A given ``lexer`` will overwrite any filename! Example::
{
"url": "https://dpaste.de/xsWd",

View file

@ -296,10 +296,10 @@ FORMAT_MAPPING = {
@csrf_exempt
def snippet_api(request):
content = request.POST.get('content', '').strip()
lexer = request.REQUEST.get('lexer', LEXER_DEFAULT).strip()
filename = request.REQUEST.get('filename', '').strip()
expires = request.REQUEST.get('expires', '').strip()
format = request.REQUEST.get('format', 'default').strip()
lexer = request.POST.get('lexer', LEXER_DEFAULT).strip()
filename = request.POST.get('filename', '').strip()
expires = request.POST.get('expires', '').strip()
format = request.POST.get('format', 'default').strip()
if not content:
return HttpResponseBadRequest('No content given')