Documentation
¶
Index ¶
Constants ¶
const DefaultAddr = ":9418"
DefaultAddr is the default address to listen on for Git protocol server.
Variables ¶
var DefaultBackend = gitbackend.NewBackend(nil)
DefaultBackend is the default global Git transport server handler.
var ErrServerClosed = errors.New("server closed")
ErrServerClosed indicates that the server has been closed.
var ServerContextKey = &contextKey{"git-server"}
ServerContextKey is the context key used to store the server in the context.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler interface { // ServeTCP handles a TCP connection for the Git protocol. ServeTCP(ctx context.Context, c io.ReadWriteCloser, req *packp.GitProtoRequest) }
Handler is the interface that handles TCP requests for the Git protocol.
type HandlerFunc ¶
type HandlerFunc func(ctx context.Context, c io.ReadWriteCloser, req *packp.GitProtoRequest)
HandlerFunc is a function that implements the Handler interface.
func LoggingMiddleware ¶
func LoggingMiddleware(logger Logger, next Handler) HandlerFunc
func (HandlerFunc) ServeTCP ¶
func (f HandlerFunc) ServeTCP(ctx context.Context, c io.ReadWriteCloser, req *packp.GitProtoRequest)
ServeTCP implements the Handler interface.
type Server ¶
type Server struct { // Addr is the address to listen on. If empty, it defaults to ":9418". Addr string // Handler is the handler for Git protocol requests. It uses // [DefaultHandler] when nil. Handler Handler // ErrorLog is the logger used to log errors. When nil, it won't log // errors. ErrorLog *log.Logger // BaseContext optionally specifies a function to create a base context for // the server listeners. If nil, [context.Background] will be used. // The provided listener is the specific listener that is about to start // accepting connections. BaseContext func(net.Listener) context.Context // ConnContext optionally specifies a function to create a context for each // connection. If nil, the context will be derived from the server's base // context. ConnContext func(context.Context, net.Conn) context.Context // contains filtered or unexported fields }
Server is a TCP server that handles Git protocol requests.
func (*Server) Close ¶
Close immediately closes the server and all active connections. It returns any error returned from closing the underlying listeners.
func (*Server) ListenAndServe ¶
ListenAndServe listens on the TCP network address and serves Git protocol requests using the provided handler.