routing

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package routing provides dynamic routing capabilities for the Hapax server. It implements versioned API routing, health checks, and dynamic middleware configuration through YAML configuration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Router

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

Router handles dynamic HTTP routing with versioning and health checks. It provides: - Version-based routing (v1, v2, etc.) - Dynamic middleware configuration - Health check monitoring - Header validation - Method restrictions

func NewRouter

func NewRouter(cfg *config.Config, handlers map[string]http.Handler, logger *zap.Logger) *Router

NewRouter creates a new router with the given configuration. It initializes the router with global middleware and configures all routes based on the provided configuration.

Parameters:

  • cfg: Server configuration containing route definitions
  • handlers: Map of handler names to their implementations
  • logger: Logger instance for error and debug logging

Returns:

  • *Router: Configured router instance

func (*Router) ServeHTTP

func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP implements the http.Handler interface. Delegates request handling to the underlying Chi router.

Jump to

Keyboard shortcuts

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