Documentation
¶
Overview ¶
Package adapters provides framework-neutral helpers used by optional framework adapter modules.
Index ¶
- func CleanRoutePath(value string) (string, error)
- func HandlerWithPrefix(prefix string, handler http.Handler) (http.Handler, error)
- func JoinPrefix(prefix string, routePath string) (string, error)
- func NormalizeMountPrefix(prefix string) (string, error)
- func OpenAPIWithServerURL(spec []byte, serverURL string) ([]byte, error)
- func RebaseLocalURL(prefix string, value string) string
- func TranslatePattern(routePath string, style PatternStyle) (string, error)
- type PatternStyle
- type Route
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanRoutePath ¶
CleanRoutePath normalizes a route path while rejecting values that cannot be mounted as HTTP path patterns.
func HandlerWithPrefix ¶
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 ¶
JoinPrefix prefixes a route path or translated host route pattern.
func NormalizeMountPrefix ¶
NormalizeMountPrefix cleans a host-app mount prefix. The empty string and "/" both mean no prefix.
func OpenAPIWithServerURL ¶
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 ¶
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 ¶
Route describes one routable generated HTTP surface from GOWDK metadata.
func RoutesFromOpenAPI ¶
RoutesFromOpenAPI extracts deterministic method/path records from a GOWDK OpenAPI report.