{"modulePath":"github.com/bitechdev/ResolveSpec","version":"v1.3.5","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package quickproxy\n\nPackage quickproxy provides a small reverse-proxy layer that tries a set of configured upstream targets first, and falls back to a caller-supplied http.Handler (typically static file serving) when the upstream is unreachable or returns 404.\n\n## Constants\n\n```go\nconst DefaultTimeout = 10 * time.Second\n```\nDefaultTimeout is the dial and response-header timeout applied to upstream requests when no WithTimeout option is given. It does not limit response body streaming.\n\n## Types\n\n```go\ntype Option func(*options)\n```\nOption configures a Service.\n\n```go\nfunc WithTimeout(d time.Duration) Option\n```\nWithTimeout sets the dial and response-header timeout used when connecting to upstream targets. It does not limit response body streaming, so it won't interrupt long-lived downloads or SSE/WebSocket connections once established.\n\n```go\ntype Rule struct {\n\t// URLPrefix is the URL path prefix this rule matches. Must start with \"/\".\n\tURLPrefix string\n\n\t// Target is the upstream base URL, e.g. \"http://localhost:3000\".\n\t// The incoming request path and query are forwarded unchanged; only the\n\t// scheme and host are rewritten to Target's.\n\tTarget string\n\n\t// Exclude is a list of URL path prefixes that this rule should not\n\t// proxy, even though they fall under URLPrefix. Each entry is a full\n\t// path from root and must itself start with URLPrefix (e.g. rule\n\t// URLPrefix \"/api\" excluding a subpath must use \"/api/health\", not\n\t// \"/health\"). A request matching an Exclude prefix is treated as if\n\t// this rule didn't match at all: matching continues against any other\n\t// configured rule, falling back if none match. This is typically used\n\t// to carve out paths (e.g. \"/health\") from a catch-all \"/\" rule so\n\t// they're served by the fallback handler instead of being proxied.\n\tExclude []string\n}\n```\nRule maps a URL path prefix to an upstream target. A Rule with URLPrefix \"/\" acts as a catch-all passthrough.\n\n```go\ntype Service struct {\n\t// contains filtered or unexported fields\n}\n```\nService holds a compiled set of proxy rules and performs longest-prefix matching against them. A Service is safe for concurrent use once returned from NewService; Handler must be called once per Service to wire up the fallback handler before the returned http.Handler is served.\n\n```go\nfunc NewService(rules []Rule, opts ...Option) (*Service, error)\n```\nNewService compiles the given rules into a Service. Rules are matched by longest URLPrefix, so a catch-all \"/\" rule can coexist with more specific rules such as \"/api\".\n\n```go\nfunc (s *Service) Handler(fallback http.Handler) http.Handler\n```\nHandler returns an http.Handler that tries the configured proxy rules first (longest-prefix match), and calls fallback when no rule matches, the upstream is unreachable, or the upstream returns 404. Any other upstream response (2xx, other 4xx, 5xx) is streamed through to the client unchanged.\n\nHandler wires up ErrorHandler on the Service's compiled rules, so it should be called once per Service, before the returned http.Handler starts serving requests.\n\n","path":"github.com/bitechdev/ResolveSpec/pkg/server/quickproxy","name":"quickproxy","synopsis":"Package quickproxy provides a small reverse-proxy layer that tries a set of configured upstream targets first, and falls back to a caller-supplied http.Handler (typically static file serving) when the upstream is unreachable or returns 404.","isRedistributable":true}
