根据Go中的接收器类型更改功能行为

I want the behavior of a function to change based on the receiver. Or really, I want a method to be able to take in different receivers as input. For instance

type handler func(http.ResponseWriter, *http.Request, *Context)
type requireloggedinhandler handler

func (h handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
  ctx := setupContext(...)
  // NEXT LINE IS THE KEY LINE
  if (reflect.TypeOf(h) == main.requireloggedinhandler) {
     if !checkedLoggedIn(ctx) {
         http.Redirect(...)
         return
     }
  }

  h(w, r, ctx)
}

But the issue is once we get to ServeHTTP the type has to be handler, not requireloggedinhandler. eg this won't work

r.HandleFunc("/", requireloggedinhandler(MyFunc).ServeHTTP)

Can I enter ServeHTTP as an inherited interface of handler?

Don't use r.HandleFunc use straight r.Handle("/", MyFunc)