Documentation ¶
Overview ¶
Package static provides a modifier that allows Martian to return static files local to Martian. The static modifier does not support setting explicit path mappings via the JSON API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Modifier ¶
type Modifier struct {
// contains filtered or unexported fields
}
Modifier is a martian.RequestResponseModifier that routes reqeusts to rootPath and serves the assets there, while skipping the HTTP roundtrip.
func NewModifier ¶
NewModifier constructs a static.Modifier that takes a path to serve files from, as well as an optional mapping of request paths to local file paths (still rooted at rootPath).
func (*Modifier) ModifyRequest ¶
ModifyRequest marks the context to skip the roundtrip and downgrades any https requests to http.
func (*Modifier) ModifyResponse ¶
ModifyResponse reads the file rooted at rootPath joined with the request URL path. In the case that the the request path is a key in s.explicitPaths, ModifyRequest will attempt to open the file located at s.rootPath joined by the value in s.explicitPaths (keyed by res.Request.URL.Path). In the case that the file cannot be found, the response will be a 404. ModifyResponse will return a 404 for any path that is defined in s.explictPaths and that does not exist locally, even if that file does exist in s.rootPath.
func (*Modifier) SetExplicitPathMappings ¶
SetExplicitPathMappings sets an optional mapping of request paths to local file paths rooted at s.rootPath.