Skip to content

Instantly share code, notes, and snippets.

@doug
Last active August 29, 2015 14:08
Show Gist options
  • Save doug/717966d85b3895d1a644 to your computer and use it in GitHub Desktop.
Save doug/717966d85b3895d1a644 to your computer and use it in GitHub Desktop.
yep nope http handler
package yepnope
import (
"net/http"
)
func YepNope(test func(r *http.Request) bool, yep http.Handler, nope http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
if test(r) {
yep.ServeHTTP(rw, r)
return
}
nope.ServeHTTP(rw, r)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment