finish switching params->query

Signed-off-by: kim (grufwub) <grufwub@gmail.com>
development
kim (grufwub) 4 years ago
parent ad0545b49e
commit c31b04c745

@ -163,11 +163,11 @@ func remapRequestEnabled(request *Request) bool {
raw = remap.Regex.ExpandString(raw, remap.Template, request.Path().Selector(), submatches)
}
// Split to new path and paramters again
path, params := SplitBy(string(raw), "?")
// Split to new path and query again
path, query := SplitBy(string(raw), "?")
// Remap request, log, return
request.Remap(path, params)
request.Remap(path, query)
return true
}
return false

@ -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)

Loading…
Cancel
Save