Skip to content

Instantly share code, notes, and snippets.

@heppu
Last active January 26, 2019 11:16
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 heppu/c783c4ec92bb5cbd481efd729a0ec431 to your computer and use it in GitHub Desktop.
Save heppu/c783c4ec92bb5cbd481efd729a0ec431 to your computer and use it in GitHub Desktop.
type FailingStorage struct{}
func (f *FailingStorage) Add(k, v string) (err error) {
return errors.New("now we fail")
}
var s = NewSafeStorage(&FailingStorage{})
func handleAdd(w http.ResponseWriter, r *http.Request) {
key := r.Host
value := r.Method
if err := s.Add(key, value); err != nil {
http.Error(w, e, http.StatusInternalServerError)
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment