github.com/searKing/golang/go@v1.2.117/net/mux/handler.go (about)

     1  // Copyright 2020 The searKing Author. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package mux
     6  
     7  import "net"
     8  
     9  type HandlerConn interface {
    10  	Serve(net.Conn)
    11  }
    12  
    13  // HandlerConnFunc is a match that can also write response (say to do handshake).
    14  type HandlerConnFunc func(net.Conn)
    15  
    16  func (f HandlerConnFunc) Serve(c net.Conn) {
    17  	f(c)
    18  }
    19  
    20  var ignoreErrorHandler = ErrorHandlerFunc(func(_ error) bool { return true })
    21  
    22  type ErrorHandler interface {
    23  	Continue(error) bool
    24  }
    25  
    26  // ErrorHandler handles an error and returns whether
    27  // the mux should continue serving the listener.
    28  type ErrorHandlerFunc func(error) bool
    29  
    30  func (f ErrorHandlerFunc) Continue(err error) bool {
    31  	return f(err)
    32  }