diff --git a/Writing-Middleware.md b/Writing-Middleware.md index b960c6b..92ad244 100644 --- a/Writing-Middleware.md +++ b/Writing-Middleware.md @@ -14,15 +14,15 @@ Handlers are usually a struct with at least one field, the next Handler in the c ```go type MyHandler struct { - Next middleware.HandlerFunc + Next middleware.Handler } ``` -It must implement the middleware.Handler interface. We do this by adding a method called ServeHTTP, which happens to be a middlware.HandlerFunc. Right now, let's just pass the request to the next Handler in the chain: +It must also implement the middleware.Handler interface. We do this by adding a method called ServeHTTP. Right now, let's just pass the request to the next Handler in the chain: ```go func (h MyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error) { - return h.Next(w, r) + return h.Next.ServeHTTP(w, r) } ```