routes

package
v0.0.0-...-af95b3a Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2026 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(mux *http.ServeMux, routes []Route)

Register registers routes with the router.

func Static

func Static(mux *http.ServeMux, filesys fs.FS, pattern, filepath string)

Types

type ErrorResponse

type ErrorResponse struct {
	Message string
}

type InvalidJsonError

type InvalidJsonError struct {
	Message string
}

type Route

type Route struct {
	Pattern string
	Handler http.Handler
	ReqType any
	ResType any
}

Route describes an API endpoint.

func HTTP

func HTTP(pattern string, handler http.HandlerFunc) Route

HTTP creates a raw HTTP handler route.

func RPC

func RPC[T, U any](path string, handler RpcHandler[T, U]) Route

RPC creates a typed RPC endpoint (POST, JSON request/response).

func SimpleHealth

func SimpleHealth() []Route

type RpcHandler

type RpcHandler[T, U any] func(context.Context, T) (U, error)

type ValidationError

type ValidationError struct {
	Errors []string
}

func (*ValidationError) Error

func (e *ValidationError) Error() string

type Validator

type Validator interface {
	Valid() error
}

Validator is implemented by request types to validate themselves.

Source Files

  • errors.go
  • health.go
  • routes.go
  • rpc.go

Jump to

Keyboard shortcuts

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