route

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: MIT Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package route implements the CoreC RESTful API gateway: HTTP routing, middleware (CORS, rate limiting, authentication, request metrics), request handlers, WebSocket streams, and Prometheus-format metrics exposition.

Index

Constants

This section is empty.

Variables

View Source
var (
	ReloadFunc    func(path, payload string) error
	PatchFunc     func(patch map[string]any) error
	GetConfigFunc func() *core.Config

	// Version is the build version, injected via ldflags:
	//   -ldflags "-X github.com/CoreC-Dev/CoreC/hub/route.Version=1.0.0"
	// Default "dev" for local/test builds.
	Version = "dev"
)

Functions

func CloseServer

func CloseServer() error

func ReCreateServer

func ReCreateServer(cfg *Config)

func SetEngine

func SetEngine(e core.Engine)

Types

type Config

type Config struct {
	Addr   string
	Secret string

	// TLS support (M1). When both are set, the server uses HTTPS.
	TLSCert string
	TLSKey  string

	// AllowedOrigins restricts CORS to specific origins (M3).
	// Empty means permissive default (Access-Control-Allow-Origin: *).
	AllowedOrigins []string

	// RateLimitPerSec limits requests per second per IP (M2).
	// 0 means no limit.
	RateLimitPerSec int

	// HTTP server timeouts. Zero values fall back to defaults, except for
	// ReadTimeout and WriteTimeout whose default is 0 (disabled) so that
	// long-lived WebSocket connections are not killed by an absolute
	// deadline. Set them explicitly to enable absolute deadlines.
	ReadHeaderTimeout time.Duration
	ReadTimeout       time.Duration
	WriteTimeout      time.Duration
	IdleTimeout       time.Duration

	// PprofDisabled controls whether pprof profiling endpoints are
	// disabled. Default false (pprof enabled, backward compatible).
	// Set to true to disable pprof entirely.
	PprofDisabled bool

	// PprofAddr, when non-empty, starts a separate HTTP server for pprof
	// endpoints on this address. This keeps profiling endpoints off the
	// main API port. When empty, pprof is registered on the main server
	// (unless PprofDisabled is true). The separate server does NOT require
	// authentication, so it should only be bound to a loopback or
	// private interface.
	PprofAddr string
}

Jump to

Keyboard shortcuts

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