Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

net/http: raven.RecoveryHandler cannot be passed into mux.Handle #78

Open
@linusthe3rd

Description

If I create a new HTTP handler like so:

fooHandler, err := handlers.NewFooHandler()
if err != nil {
    log.Fatalf("Error: %s", err)
}

mux := http.NewServeMux()
mux.Handle("/foo/", raven.RecoveryHandler(fooHandler))

I get the following two exceptions:

cannot use fooHandler (type *handlers.SnsBounceHandler) as type func(http.ResponseWriter, *http.Request) in argument to raven.RecoveryHandler

cannot use raven.RecoveryHandler(snsBh) (type func(http.ResponseWriter, *http.Request)) as type http.Handler in argument to mux.Handle:
    func(http.ResponseWriter, *http.Request) does not implement http.Handler (missing ServeHTTP method)

It looks like two things are occurring here:

  1. Custom objects that implement the http.Handler interface are not accepted in the raven.RecoveryHandler function.
  2. One cannot use the raven.RecoverHandler function with mux.Handle because RecoveryHandler returns a function handler instead of a http.Handle object.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions