func loggingMiddleware(next http.Handler) http.Handler {
  return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    // remainder omitted...

    if swriter.status >= 400 {
      fields = append(fields,
        zap.Error(fmt.Errorf("Inbound request failed with status %d", swriter.status)))
      logger.Error("", fields...)
    } else {
      logger.Info("Inbound request succeeded", fields...)
    }
  }
}