Refactor micropub into a class-based view so that it can have a GET handler implemented as well (since that's needed to query for config info and stuff)
This commit is contained in:
parent
b47716249e
commit
b8a8cd62cf
1 changed files with 43 additions and 39 deletions
|
@ -1,8 +1,9 @@
|
|||
from django.contrib.auth import get_user_model
|
||||
from django.http import HttpResponse
|
||||
from django.urls import reverse
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from django.views.decorators.http import require_POST
|
||||
from urllib.parse import urljoin
|
||||
|
||||
from entries.jobs import ping_hub, send_mentions
|
||||
|
@ -12,9 +13,9 @@ from lemoncurry import utils
|
|||
from lemonauth import tokens
|
||||
|
||||
|
||||
@csrf_exempt
|
||||
@require_POST
|
||||
def micropub(request):
|
||||
@method_decorator(csrf_exempt, name='dispatch')
|
||||
class MicropubView(View):
|
||||
def post(self, request):
|
||||
auth = request.META.get('HTTP_AUTHORIZATION', '').split(' ')
|
||||
if auth[0] != 'Bearer':
|
||||
return utils.bad_req('only Bearer auth supported')
|
||||
|
@ -54,3 +55,6 @@ def micropub(request):
|
|||
res = HttpResponse(status=201)
|
||||
res['Location'] = perma
|
||||
return res
|
||||
|
||||
|
||||
micropub = MicropubView.as_view()
|
||||
|
|
Loading…
Reference in a new issue