summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..42e64cf
--- /dev/null
+++ b/main.go
@@ -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))
+ }
+}