Browse Source

Add a Link header to the Micropub create response indicating the entry's shortlink

tags/v1.9.8
Danielle McLean 1 year ago
parent
commit
eb20cc1d21
Signed by: Danielle McLean <dani@00dani.me> GPG Key ID: D111F8C5A2560F19
1 changed files with 2 additions and 0 deletions
  1. 2
    0
      micropub/views/create.py

+ 2
- 0
micropub/views/create.py View File

@@ -73,6 +73,7 @@ def create(request):
73 73
 
74 74
     base = utils.origin(request)
75 75
     perma = urljoin(base, entry.url)
76
+    short = urljoin(base, entry.short_url)
76 77
     others = [urljoin(base, url) for url in (
77 78
         reverse('home:index'),
78 79
         reverse('entries:atom'),
@@ -86,4 +87,5 @@ def create(request):
86 87
 
87 88
     res = HttpResponse(status=201)
88 89
     res['Location'] = perma
90
+    res['Link'] = '<{}>; rel="shortlink"'.format(short)
89 91
     return res

Loading…
Cancel
Save