2016-11-14 21:06:39 +01:00
|
|
|
from django.http import HttpRequest, HttpResponse
|
2016-12-31 05:31:01 +01:00
|
|
|
from django.views.decorators.csrf import csrf_exempt
|
2016-11-23 20:15:23 +01:00
|
|
|
from .github_webhook.view import api_github_webhook
|
|
|
|
from .github.view import api_github_landing
|
2016-11-14 21:06:39 +01:00
|
|
|
|
2016-12-31 05:31:01 +01:00
|
|
|
# Since this dispatcher is an API-style endpoint, it needs to be
|
|
|
|
# explicitly marked as CSRF-exempt
|
|
|
|
@csrf_exempt
|
2017-11-04 07:47:46 +01:00
|
|
|
def api_github_webhook_dispatch(request: HttpRequest) -> HttpResponse:
|
2016-11-14 21:06:39 +01:00
|
|
|
if request.META.get('HTTP_X_GITHUB_EVENT'):
|
|
|
|
return api_github_webhook(request)
|
|
|
|
else:
|
|
|
|
return api_github_landing(request)
|