humago

package
v2.19.0 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2024 License: MIT Imports: 9 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MultipartMaxMemory int64 = 8 * 1024

MultipartMaxMemory is the maximum memory to use when parsing multipart form data.

Functions

func New

func New(m Mux, config huma.Config) huma.API

New creates a new Huma API using an HTTP mux.

mux := http.NewServeMux()
api := humago.New(mux, huma.DefaultConfig("My API", "1.0.0"))

func NewAdapter

func NewAdapter(m Mux, prefix string) huma.Adapter

NewAdapter creates a new adapter for the given HTTP mux.

func NewContext

func NewContext(op *huma.Operation, r *http.Request, w http.ResponseWriter) huma.Context

NewContext creates a new Huma context from an HTTP request and response.

func NewWithPrefix added in v2.11.0

func NewWithPrefix(m Mux, prefix string, config huma.Config) huma.API

NewWithPrefix creates a new Huma API using an HTTP mux with a URL prefix. This behaves similar to other router's group functionality, adding the prefix before each route path (but not in the OpenAPI). The prefix should be used in combination with the `OpenAPI().Servers` base path to ensure the correct URLs are generated in the OpenAPI spec.

mux := http.NewServeMux()
config := huma.DefaultConfig("My API", "1.0.0")
config.Servers = []*huma.Server{{URL: "http://example.com/api"}}
api := humago.NewWithPrefix(mux, "/api", config)

Types

type Mux added in v2.11.0

type Mux interface {
	HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
	ServeHTTP(http.ResponseWriter, *http.Request)
}

Jump to

Keyboard shortcuts

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