Skip to content

Instantly share code, notes, and snippets.

@adamv
Last active April 6, 2018 16:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamv/98cc6e6a6c14ae5585ff196f87e2eaeb to your computer and use it in GitHub Desktop.
Save adamv/98cc6e6a6c14ae5585ff196f87e2eaeb to your computer and use it in GitHub Desktop.
import (
"net/http"
)
func firstOrDefault(r *http.Request, key string, defaultValue string) string {
first := r.Header.Get(key)
if first != "" {
return first
}
return defaultValue
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment