summaryrefslogtreecommitdiff
path: root/main.go
blob: 42e64cf9ca4ef799934b9efdd649497556877988 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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))
	}
}