gocontroller

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package gocontroller wires providers and controllers into an existing router. It does not own the HTTP server, request context, or middleware runtime.

Index

Constants

View Source
const Version = "2.0.0"

Variables

This section is empty.

Functions

func Mount

func Mount(adapter Adapter, root *Module) error

Mount resolves constructors, composes route metadata, and registers the result on an existing router. Call it before serving requests. A native registration failure can leave earlier routes mounted; discard the router on any error.

Types

type Adapter

type Adapter interface {
	Register([]Route) error
}

Adapter registers a complete batch of routes on a host router. Implementations must validate all handler and middleware types before registering any routes. Routing, request execution, and errors remain the host framework's concern.

type Controller

type Controller interface {
	ControllerMetadata() ControllerMetadata
}

Controller declares routes using bound native framework handler methods. Implement this directly or generate it from @Controller and @Get comments.

type ControllerMetadata

type ControllerMetadata struct {
	Prefix     string
	Middleware []any
	Routes     []Route
}

type Module

type Module struct {
	Name        string
	Prefix      string
	Providers   []any
	Controllers []any
	Imports     []*Module
	Middleware  []any
}

Module groups controllers and providers. Imported prefixes and middleware nest beneath their parent. Providers are shared singletons within one Mount.

type Route

type Route struct {
	Method     string
	Path       string
	Handler    any
	Middleware []any
}

Route carries native handlers and middleware. Their types are checked by the selected adapter at mount time, before any routes are registered.

func CONNECT

func CONNECT(path string, handler any, middleware ...any) Route

func DELETE

func DELETE(path string, handler any, middleware ...any) Route

func GET

func GET(path string, handler any, middleware ...any) Route
func HEAD(path string, handler any, middleware ...any) Route

func OPTIONS

func OPTIONS(path string, handler any, middleware ...any) Route

func PATCH

func PATCH(path string, handler any, middleware ...any) Route

func POST

func POST(path string, handler any, middleware ...any) Route

func PUT

func PUT(path string, handler any, middleware ...any) Route

func TRACE

func TRACE(path string, handler any, middleware ...any) Route

Jump to

Keyboard shortcuts

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