base

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddHealthCheck

func AddHealthCheck(api huma.API, path string, serviceName string, version string)

AddHealthCheck adds a standard health check endpoint to a Huma API

func AddOpenAPICommand added in v0.1.11

func AddOpenAPICommand(cli *cobra.Command, apiProvider func() huma.API)

AddOpenAPICommand adds an OpenAPI generation command to a cobra CLI This can be used by user projects to add "openapi" command to their CLI

func CustomHealthCheck

func CustomHealthCheck(api huma.API, path string, healthFunc func(ctx context.Context) (*HealthResponse, error))

CustomHealthCheck allows users to provide their own health check logic

Types

type HealthResponse

type HealthResponse struct {
	Body struct {
		Status  string `json:"status" example:"ok" doc:"Service status"`
		Message string `json:"message,omitempty" example:"Service is running" doc:"Optional status message"`
		Version string `json:"version,omitempty" example:"1.0.0" doc:"Optional service version"`
	}
}

HealthResponse represents a standard health check response

type StaticConfig

type StaticConfig struct {
	// AssetsDir is the subdirectory within the embedded FS (e.g., "assets", "dist")
	AssetsDir string
	// SPAMode enables Single Page Application routing (serves index.html for non-file routes)
	SPAMode bool
	// DevMode disables static serving (for development when using dev server)
	DevMode bool
	// APIPrefix excludes paths starting with this prefix from static serving
	APIPrefix string
}

StaticConfig configures static file serving behavior

type StaticResponse

type StaticResponse struct {
	StatusCode   int
	ContentType  string
	CacheControl string
	Body         []byte
	NotFound     bool
}

StaticResponse contains the result of static file processing

func ServeStaticFile

func ServeStaticFile(assets embed.FS, config StaticConfig, path string) StaticResponse

ServeStaticFile is the core logic for serving static files, router-agnostic

Jump to

Keyboard shortcuts

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