diff options
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -0,0 +1,24 @@ +package main + +import ( + "net/http" + "net/url" +) + +const ( + errSrcInvalid = "source contains no valid URL" +) + +// endpoint is a webmention receiver. +type endpoint struct { + allowPrefix string +} + +// ServeHTTP is http.Handler implementation. +func (ep endpoint) ServeHTTP(w http.ResponseWriter, r *http.Request) { + _, err := url.Parse(r.PostFormValue("source")) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte(errSrcInvalid)) + } +} |