webhook

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Addr is the address to listen on (e.g., ":8080", "0.0.0.0:8080")
	Addr string

	// TLSCertFile is the path to the TLS certificate file (optional)
	TLSCertFile string

	// TLSKeyFile is the path to the TLS key file (optional)
	TLSKeyFile string

	// Handler is the HTTP handler for webhook requests
	Handler http.Handler

	// ReadTimeout is the maximum duration for reading requests (optional)
	ReadTimeout time.Duration

	// WriteTimeout is the maximum duration for writing responses (optional)
	WriteTimeout time.Duration

	// IdleTimeout is the maximum duration to wait for the next request (optional)
	IdleTimeout time.Duration

	// ShutdownTimeout is the maximum time to wait for graceful shutdown (optional)
	ShutdownTimeout time.Duration

	// Secret is the webhook secret for HMAC signature verification (optional but recommended)
	Secret string

	// RateLimit is the number of requests per minute allowed per IP (optional, default: 100)
	RateLimit int

	// MaxBodySize is the maximum request body size in bytes (optional, default: 1MB)
	MaxBodySize int64
}

Config holds configuration for the webhook server.

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represents an HTTP server for receiving GitHub webhooks. It provides graceful shutdown, TLS support, health/readiness endpoints, signature verification, rate limiting, and request size limits.

func NewServer

func NewServer(cfg Config, log *logger.Logger) (*Server, error)

NewServer creates a new webhook server with the given configuration. The server must be started with Start() and stopped with Shutdown(). Returns an error if configuration is invalid.

func (*Server) Shutdown

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

Shutdown gracefully shuts down the webhook server. It waits for in-flight requests to complete or the context to timeout. This method is safe to call multiple times.

func (*Server) Start

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

Start starts the webhook server and begins listening for requests. This method blocks until the server is shut down or an error occurs. For non-blocking operation, call this in a goroutine.

Jump to

Keyboard shortcuts

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