Documentation
¶
Index ¶
- Constants
- func FragmentRouteFromContext(ctx context.Context) *fragment.Definition
- func ParametersFromContext(ctx context.Context) map[string]string
- type GetOption
- type ResultError
- type Route
- type RouteValidationError
- type Server
- func (s *Server) Close()
- func (s *Server) CreateHandler() http.Handler
- func (s *Server) Get(path string, root *fragment.Definition, opts ...GetOption) error
- func (s *Server) ListenAndServe() error
- func (s *Server) MatchingRoute(path string) (*Route, map[string]string)
- func (s *Server) PassThroughEnabled() bool
- func (s *Server) Routes() []Route
- func (s *Server) Serve(listener net.Listener) error
- func (s *Server) Shutdown(ctx context.Context) error
- func (s *Server) Target() string
- type ServerOption
Constants ¶
View Source
const (
HeaderViewProxyOriginalPath = "X-Viewproxy-Original-Path"
)
Variables ¶
This section is empty.
Functions ¶
func FragmentRouteFromContext ¶
func FragmentRouteFromContext(ctx context.Context) *fragment.Definition
Types ¶
type Route ¶
type Route struct {
Path string
Parts []string
RootFragment *fragment.Definition
Metadata map[string]string
// contains filtered or unexported fields
}
func RouteFromContext ¶
func (*Route) FragmentOrder ¶
func (*Route) FragmentsToRequest ¶
func (r *Route) FragmentsToRequest() []*fragment.Definition
type RouteValidationError ¶
type RouteValidationError struct {
Route *Route
Fragment *fragment.Definition
}
func (*RouteValidationError) Error ¶
func (rve *RouteValidationError) Error() string
type Server ¶
type Server struct {
Addr string
// Sets the maximum duration for requests made to the target server
ProxyTimeout time.Duration
// Sets the maximum duration for reading the entire request, including the body
ReadTimeout time.Duration
// Sets the maximum duration before timing out writes of the response
WriteTimeout time.Duration
// Ignores incoming request's trailing slashes when trying to match a
// request URL to a route. This only applies to routes that are not declared
// with an explicit trailing slash.
IgnoreTrailingSlash bool
Logger logger
SecretFilter secretfilter.Filter
// Sets the secret used to generate an HMAC that can be used by the target
// server to validate that a request came from viewproxy.
//
// When set, two headers are sent to the target URL for fragment and layout
// requests. The `X-Authorization-Timestamp` header, which is a timestamp
// generated at the start of the request, and `X-Authorization`, which is a
// hex encoded HMAC of "urlPathWithQueryParams,timestamp`.
HmacSecret string
// The transport passed to `http.Client` when fetching fragments or proxying
// requests.
// HttpTransport http.RoundTripper
MultiplexerTripper multiplexer.Tripper
// A function to wrap the entire request handling with other middleware
AroundRequest func(http.Handler) http.Handler
// A function to wrap around the generating of the response after the fragment
// requests have completed or errored
AroundResponse func(http.Handler) http.Handler
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(target string, opts ...ServerOption) (*Server, error)
NewServer returns a new Server that will make requests to the given target argument.
func (*Server) CreateHandler ¶
func (*Server) ListenAndServe ¶
func (*Server) MatchingRoute ¶
TODO this should probably be a tree structure for faster lookups
func (*Server) PassThroughEnabled ¶
type ServerOption ¶
func WithPassThrough ¶
func WithPassThrough(passthroughTarget string) ServerOption
Click to show internal directories.
Click to hide internal directories.