diff --git a/anymail/urls.py b/anymail/urls.py index d4f19e1..eace41e 100644 --- a/anymail/urls.py +++ b/anymail/urls.py @@ -1,4 +1,4 @@ -from django.urls import re_path +from django.urls import path, re_path from .webhooks.amazon_ses import ( AmazonSESInboundWebhookView, @@ -18,89 +18,91 @@ from .webhooks.sparkpost import ( app_name = "anymail" urlpatterns = [ - re_path( - r"^amazon_ses/inbound/$", + path( + "amazon_ses/inbound/", AmazonSESInboundWebhookView.as_view(), name="amazon_ses_inbound_webhook", ), re_path( + # Mailgun delivers inbound messages differently based on whether + # the webhook url contains "mime" (anywhere). You can use either + # ".../mailgun/inbound/" or ".../mailgun/inbound_mime/" depending + # on the behavior you want. r"^mailgun/inbound(_mime)?/$", MailgunInboundWebhookView.as_view(), name="mailgun_inbound_webhook", ), - re_path( - r"^mailjet/inbound/$", + path( + "mailjet/inbound/", MailjetInboundWebhookView.as_view(), name="mailjet_inbound_webhook", ), - re_path( - r"^postal/inbound/$", + path( + "postal/inbound/", PostalInboundWebhookView.as_view(), name="postal_inbound_webhook", ), - re_path( - r"^postmark/inbound/$", + path( + "postmark/inbound/", PostmarkInboundWebhookView.as_view(), name="postmark_inbound_webhook", ), - re_path( - r"^sendgrid/inbound/$", + path( + "sendgrid/inbound/", SendGridInboundWebhookView.as_view(), name="sendgrid_inbound_webhook", ), - re_path( - r"^sparkpost/inbound/$", + path( + "sparkpost/inbound/", SparkPostInboundWebhookView.as_view(), name="sparkpost_inbound_webhook", ), - re_path( - r"^amazon_ses/tracking/$", + path( + "amazon_ses/tracking/", AmazonSESTrackingWebhookView.as_view(), name="amazon_ses_tracking_webhook", ), - re_path( - r"^mailgun/tracking/$", + path( + "mailgun/tracking/", MailgunTrackingWebhookView.as_view(), name="mailgun_tracking_webhook", ), - re_path( - r"^mailjet/tracking/$", + path( + "mailjet/tracking/", MailjetTrackingWebhookView.as_view(), name="mailjet_tracking_webhook", ), - re_path( - r"^postal/tracking/$", + path( + "postal/tracking/", PostalTrackingWebhookView.as_view(), name="postal_tracking_webhook", ), - re_path( - r"^postmark/tracking/$", + path( + "postmark/tracking/", PostmarkTrackingWebhookView.as_view(), name="postmark_tracking_webhook", ), - re_path( - r"^sendgrid/tracking/$", + path( + "sendgrid/tracking/", SendGridTrackingWebhookView.as_view(), name="sendgrid_tracking_webhook", ), - re_path( - r"^sendinblue/tracking/$", + path( + "sendinblue/tracking/", SendinBlueTrackingWebhookView.as_view(), name="sendinblue_tracking_webhook", ), - re_path( - r"^sparkpost/tracking/$", + path( + "sparkpost/tracking/", SparkPostTrackingWebhookView.as_view(), name="sparkpost_tracking_webhook", ), # Anymail uses a combined Mandrill webhook endpoint, # to simplify Mandrill's key-validation scheme: - re_path( - r"^mandrill/$", MandrillCombinedWebhookView.as_view(), name="mandrill_webhook" - ), + path("mandrill/", MandrillCombinedWebhookView.as_view(), name="mandrill_webhook"), # This url is maintained for backwards compatibility with earlier Anymail releases: - re_path( - r"^mandrill/tracking/$", + path( + "mandrill/tracking/", MandrillCombinedWebhookView.as_view(), name="mandrill_tracking_webhook", ), diff --git a/docs/installation.rst b/docs/installation.rst index 28fb196..d985f4c 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -142,15 +142,15 @@ If you want to use Anymail's inbound or tracking webhooks: .. code-block:: python - from django.urls import include, re_path + from django.urls import include, path urlpatterns = [ ... - re_path(r'^anymail/', include('anymail.urls')), + path("anymail/", include("anymail.urls")), ] (You can change the "anymail" prefix in the first parameter to - :func:`~django.urls.re_path` if you'd like the webhooks to be served + :func:`~django.urls.path` if you'd like the webhooks to be served at some other URL. Just match whatever you use in the webhook URL you give your ESP in the next step.) diff --git a/tests/test_settings/urls.py b/tests/test_settings/urls.py index 151ca87..b1dee6d 100644 --- a/tests/test_settings/urls.py +++ b/tests/test_settings/urls.py @@ -1,5 +1,5 @@ -from django.urls import include, re_path +from django.urls import include, path urlpatterns = [ - re_path(r"^anymail/", include("anymail.urls")), + path("anymail/", include("anymail.urls")), ]