package main import ( "math/rand" "net/http" ) func requireGet(h http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if r.Method == "GET" { h(w, r) return } http.Error(w, "get only", http.StatusMethodNotAllowed) } } func requirePost(h http.HandlerFunc) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if r.Method == "POST" { h(w, r) return } http.Error(w, "post only", http.StatusMethodNotAllowed) } } var letterRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") func RandStringRunes(n int) string { b := make([]rune, n) for i := range b { b[i] = letterRunes[rand.Intn(len(letterRunes))] } return string(b) }