Simplify url patterns

Favor `django.urls.path` over `re_path` where possible.
This commit is contained in:
medmunds
2023-02-08 14:23:15 -08:00
parent 4e3e76f997
commit f5f3fc86e6
3 changed files with 41 additions and 39 deletions

View File

@@ -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",
),