adapters

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package adapters provides framework-neutral helpers used by optional framework adapter modules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanRoutePath

func CleanRoutePath(value string) (string, error)

CleanRoutePath normalizes a route path while rejecting values that cannot be mounted as HTTP path patterns.

func HandlerWithPrefix

func HandlerWithPrefix(prefix string, handler http.Handler) (http.Handler, error)

HandlerWithPrefix strips a host-app mount prefix before dispatching to the generated GOWDK handler and rebases local generated URLs back under the mount prefix in Location headers and HTML bodies.

func JoinPrefix

func JoinPrefix(prefix string, routePath string) (string, error)

JoinPrefix prefixes a route path or translated host route pattern.

func NormalizeMountPrefix

func NormalizeMountPrefix(prefix string) (string, error)

NormalizeMountPrefix cleans a host-app mount prefix. The empty string and "/" both mean no prefix.

func OpenAPIWithServerURL

func OpenAPIWithServerURL(spec []byte, serverURL string) ([]byte, error)

OpenAPIWithServerURL returns spec with a single servers entry for the mount URL. Use this when generated routes are served below a host-app prefix.

func RebaseLocalURL

func RebaseLocalURL(prefix string, value string) string

RebaseLocalURL returns value under prefix when value is a same-origin root-relative URL. Absolute URLs, protocol-relative or slash-backslash URLs, relative URLs, and already-prefixed URLs are returned unchanged.

func TranslatePattern

func TranslatePattern(routePath string, style PatternStyle) (string, error)

TranslatePattern converts a GOWDK route pattern into the selected host router syntax. GOWDK params use {name}, {name:type}, or final {name...} segments.

Types

type PatternStyle

type PatternStyle string

PatternStyle selects a host router pattern syntax.

const (
	// PatternChi translates GOWDK params to chi's {name} syntax.
	PatternChi PatternStyle = "chi"
	// PatternEcho translates GOWDK params to Echo's :name and * syntax.
	PatternEcho PatternStyle = "echo"
	// PatternGin translates GOWDK params to Gin's :name and *name syntax.
	PatternGin PatternStyle = "gin"
)

type Route

type Route struct {
	Method string
	Path   string
}

Route describes one routable generated HTTP surface from GOWDK metadata.

func RoutesFromOpenAPI

func RoutesFromOpenAPI(spec []byte) ([]Route, error)

RoutesFromOpenAPI extracts deterministic method/path records from a GOWDK OpenAPI report.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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