package main import ( "fmt" "net/http" "github.com/gorilla/mux" ) func handleRequest(w http.ResponseWriter, req *http.Request) { vars := mux.Vars(req) var fOk, uidOk bool var f, uid string f, fOk = vars["function"] uid, uidOk = vars["uid"] if !fOk || !uidOk { // Not sure what you want me to do here, Hoss. http.Error(w, "You did a bad", 400) return } switch f { case "rss": handleRssFeed(uid, w) default: http.Error(w, "You did a bad", 400) } } func handleRssFeed(uid string, w http.ResponseWriter) { w.Header().Set("Content-Type", "application/xml") v, err := buildRssFeed(uid) if err != nil { http.Error(w, err.Error(), 400) return } fmt.Fprint(w, v) }