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
|
2017-11-16 00:43:10 +01:00
|
|
|
|
2018-04-18 21:20:25 +02:00
|
|
|
from .github_legacy.view import api_github_landing
|
2017-11-16 00:43:10 +01:00
|
|
|
from .github_webhook.view import api_github_webhook
|
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'):
|
2018-03-14 17:45:43 +01:00
|
|
|
return api_github_webhook(request) # type: ignore # mypy doesn't seem to apply the decorator
|
2016-11-14 21:06:39 +01:00
|
|
|
else:
|
2018-03-14 17:45:43 +01:00
|
|
|
return api_github_landing(request) # type: ignore # mypy doesn't seem to apply the decorator
|