|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
package core
|
|
|
|
|
|
|
|
|
|
// Request is a data structure for storing a filesystem path, and params, parsed from a client's request
|
|
|
|
|
// Request is a data structure for storing a filesystem path, and query, parsed from a client's request
|
|
|
|
|
type Request struct {
|
|
|
|
|
path *Path
|
|
|
|
|
query string
|
|
|
|
@ -25,14 +25,14 @@ func (r *Request) Query() string {
|
|
|
|
|
return r.query
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// AddToQuery adds provided params to beginning of params, formatting as necessary
|
|
|
|
|
// AddToQuery adds provided query to beginning of existing query, formatting as necessary
|
|
|
|
|
func (r *Request) AddToQuery(query string) {
|
|
|
|
|
// Ensure we have been given params
|
|
|
|
|
// Ensure we have been given query
|
|
|
|
|
if len(query) < 1 {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Either append or set params
|
|
|
|
|
// Either append or set query
|
|
|
|
|
if len(r.query) > 0 {
|
|
|
|
|
r.query = query + "&" + r.query
|
|
|
|
|
} else {
|
|
|
|
@ -40,13 +40,13 @@ func (r *Request) AddToQuery(query string) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Remap modifies a request to use new relative path, and accommodate supplied extra parameters if provided
|
|
|
|
|
// Remap modifies a request to use new relative path, and accommodate supplied extra query if provided
|
|
|
|
|
func (r *Request) Remap(rel, query string) {
|
|
|
|
|
r.AddToQuery(query)
|
|
|
|
|
r.path.Remap(rel)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// RemapDirect modifies a request to use new absolute path, and accomodate supplied extra parameters if provided
|
|
|
|
|
// RemapDirect modifies a request to use new absolute path, and accomodate supplied extra query if provided
|
|
|
|
|
func (r *Request) RemapDirect(abs, query string) {
|
|
|
|
|
r.AddToQuery(query)
|
|
|
|
|
r.path.RemapDirect(abs)
|
|
|
|
|