git

package
v0.0.0-...-edad503 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultAddr = ":9418"

DefaultAddr is the default address to listen on for Git protocol server.

Variables

View Source
var DefaultBackend = gitbackend.NewBackend(nil)

DefaultBackend is the default global Git transport server handler.

View Source
var ErrServerClosed = errors.New("server closed")

ErrServerClosed indicates that the server has been closed.

View Source
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

ServeTCP implements the Handler interface.

type Logger

type Logger interface {
	Printf(format string, v ...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

func (s *Server) Close() error

Close immediately closes the server and all active connections. It returns any error returned from closing the underlying listeners.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe listens on the TCP network address and serves Git protocol requests using the provided handler.

func (*Server) Serve

func (s *Server) Serve(ln net.Listener) error

Serve starts the server and listens for incoming connections on the given listener.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown gracefully shuts down the server, waiting for all active connections to finish.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL