diff --git a/Pipfile b/Pipfile index b2667f4..571983f 100644 --- a/Pipfile +++ b/Pipfile @@ -12,4 +12,4 @@ django = "==2.1.3" channels = "==2.1.5" [requires] -python_version = "3.6.6" +python_version = "3.6.7" diff --git a/Pipfile.lock b/Pipfile.lock index b52ee85..841a94b 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,11 +1,11 @@ { "_meta": { "hash": { - "sha256": "66738ee2668e8f81f37915ccb063d01fbcfda955ccb5aa932f8187ee8c53cf1f" + "sha256": "a1a6318c9a51fe4cd91cc030c573f2852081fa92365053bade1dcbbe3c3a96a0" }, "pipfile-spec": 6, "requires": { - "python_version": "3.6.6" + "python_version": "3.6.7" }, "sources": [ { @@ -105,10 +105,7 @@ "pyhamcrest": { "hashes": [ "sha256:6b672c02fdf7470df9674ab82263841ce8333fb143f32f021f6cb26f0e512420", - "sha256:7a4bdade0ed98c699d728191a058a60a44d2f9c213c51e2dd1e6fb42f2c6128a", - "sha256:8ffaa0a53da57e89de14ced7185ac746227a8894dbd5a3c718bf05ddbd1d56cd", - "sha256:bac0bea7358666ce52e3c6c85139632ed89f115e9af52d44b3c36e0bf8cf16a9", - "sha256:f30e9a310bcc1808de817a92e95169ffd16b60cbc5a016a49c8d0e8ababfae79" + "sha256:8ffaa0a53da57e89de14ced7185ac746227a8894dbd5a3c718bf05ddbd1d56cd" ], "version": "==1.9.0" }, @@ -184,10 +181,10 @@ }, "autopep8": { "hashes": [ - "sha256:1b8d42ebba751a91090d3adb5c06840b1151d71ed43e1c7a9ed6911bfe8ebe6c" + "sha256:33d2b5325b7e1afb4240814fe982eea3a92ebea712869bfd08b3c0393404248c" ], "index": "pypi", - "version": "==1.4.2" + "version": "==1.4.3" }, "isort": { "hashes": [ @@ -240,7 +237,6 @@ }, "pycodestyle": { "hashes": [ - "sha256:74abc4e221d393ea5ce1f129ea6903209940c1ecd29e002e8c6933c2b21026e0", "sha256:cbc619d09254895b0d12c2c691e237b2e91e9b2ecf5e84c26b35400f93dcfb83", "sha256:cbfca99bd594a10f674d0cd97a3d802a1fdef635d4361e1a2658de47ed261e3a" ], diff --git a/callbacks/__init__.py b/callbacks/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/callbacks/apps.py b/callbacks/apps.py new file mode 100644 index 0000000..1d69586 --- /dev/null +++ b/callbacks/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class CallbacksConfig(AppConfig): + name = 'callbacks' diff --git a/callbacks/templates/callbacks/check.html b/callbacks/templates/callbacks/check.html new file mode 100644 index 0000000..983c099 --- /dev/null +++ b/callbacks/templates/callbacks/check.html @@ -0,0 +1,10 @@ + + + + + + + Webhook Logger + + + diff --git a/callbacks/tests.py b/callbacks/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/callbacks/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/callbacks/views.py b/callbacks/views.py new file mode 100644 index 0000000..213df24 --- /dev/null +++ b/callbacks/views.py @@ -0,0 +1,28 @@ +from django.views.generic import RedirectView, TemplateView, View +from django.urls import reverse_lazy +from uuid import uuid4 + + +class HomeView(RedirectView): + """Initial page, just sends the visitor to an unique url""" + + def get_redirect_url(self): + uuid = str(uuid4()) + return f"{reverse_lazy('callback-check')}?cb={uuid}" + + +class CheckView(TemplateView): + """Renders the page where users can monitor webhook + + The activity shown is filtered by the unique ID assigned to + the visitor + """ + template_name = 'callbacks/check.html' + + +class CallbackView(View): + """Webhook receiver view + + This view receives any HTTP request, collects all the information + possible about the request, then sends it through the proper channel + """ diff --git a/webhook_logger/settings.py b/webhook_logger/settings.py index d3f5f96..adc1dac 100644 --- a/webhook_logger/settings.py +++ b/webhook_logger/settings.py @@ -32,7 +32,8 @@ ALLOWED_HOSTS = [] INSTALLED_APPS = [ 'django.contrib.staticfiles', - 'channels' + 'channels', + 'callbacks' ] MIDDLEWARE = [ @@ -94,4 +95,5 @@ STATIC_URL = '/static/' # Django Channels + ASGI_APPLICATION = "webhook_logger.routing.application" diff --git a/webhook_logger/urls.py b/webhook_logger/urls.py index 73744cb..186d815 100644 --- a/webhook_logger/urls.py +++ b/webhook_logger/urls.py @@ -14,6 +14,10 @@ Including another URLconf 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ from django.urls import path +from callbacks.views import HomeView, CheckView, CallbackView urlpatterns = [ + path('check', CheckView.as_view(), name='callback-check'), + path('submit/', CallbackView.as_view(), name='callback-submit'), + path('', HomeView.as_view(), name='callback-home') ]