From 80eac2568e334d630f24b437758a60badbb2589d Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Wed, 19 Jun 2019 21:26:18 +0200 Subject: [PATCH] Support xkey purge requests on the API endpoint Simply specigfying "x" instead o "p" should do the trick. --- pgweb/core/views.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pgweb/core/views.py b/pgweb/core/views.py index 6e256f1f..c1d34d12 100644 --- a/pgweb/core/views.py +++ b/pgweb/core/views.py @@ -328,8 +328,11 @@ def api_varnish_purge(request): n = int(request.POST['n']) curs = connection.cursor() for i in range(0, n): - expr = request.POST['p%s' % i] - curs.execute("SELECT varnish_purge_expr(%s)", (expr, )) + if 'p{0}'.format(i) in request.POST: + curs.execute("SELECT varnish_purge_expr(%s)", (request.POST['p{0}'.format(i)], )) + if 'x{0}'.format(i) in request.POST: + curs.execute("SELECT varnish_purge_xkey(%s)", (request.POST['x{0}'.format(i)], )) + return HttpResponse("Purged %s entries\n" % n) -- 2.39.5