Documentation
¶
Overview ¶
Package router is a micro plugin for defining HTTP routes
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Default config source file DefaultFile = "routes.json" DefaultPath = []string{"api"} DefaultLogger = logrus.New() )
Functions ¶
Types ¶
type Request ¶
type Request struct {
Method string `json:"method"`
Header map[string]string `json:"header"`
Host string `json:"host"`
Path string `json:"path"`
Query map[string]string `json:"query"`
}
Request describes the expected request and will attempt to match all fields specified
type Response ¶
type Response struct {
Status string `json:"status"`
StatusCode int `json:"status_code"`
Header map[string]string `json:"header"`
Body []byte `json:"body"`
}
Response is put into the http.Response for a Request
type Route ¶
type Route struct {
Request Request `json:"request"`
Response Response `json:"response"`
ProxyURL URL `json:"proxy_url"`
Priority int `json:"priority"` // 0 is highest. Used for ordering routes
Weight float64 `json:"weight"` // percentage weight between 0 and 1.0
Type string `json:"type"` // proxy or response. Response is default
}
Route describes a single route which is matched on Request and if so, will return the Response
Click to show internal directories.
Click to hide internal directories.