mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-03-11 15:34:56 +00:00
lib/httpserver: link to url format docs in error message emitted on parse error for the provided url path
This should help users identifying and fixing improperly set up urls. Updates https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3402
This commit is contained in:
parent
20ceb3a2ca
commit
027ab74efb
1 changed files with 10 additions and 10 deletions
|
@ -6,9 +6,7 @@ import (
|
|||
)
|
||||
|
||||
// Path contains the following path structure:
|
||||
// /{prefix}/{authToken}/{suffix}
|
||||
//
|
||||
// It is compatible with SaaS version.
|
||||
// /{prefix}/{tenantID}/{suffix}
|
||||
type Path struct {
|
||||
Prefix string
|
||||
AuthToken string
|
||||
|
@ -18,11 +16,11 @@ type Path struct {
|
|||
// ParsePath parses the given path.
|
||||
func ParsePath(path string) (*Path, error) {
|
||||
// The path must have the following form:
|
||||
// /{prefix}/{authToken}/{suffix}
|
||||
// /{prefix}/{tenantID}/{suffix}
|
||||
//
|
||||
// - prefix must contain `select`, `insert` or `delete`.
|
||||
// - authToken contains `accountID[:projectID]`, where projectID is optional.
|
||||
// authToken may also contain `multitenant` string. In this case the accountID and projectID
|
||||
// - tenantID contains `accountID[:projectID]`, where projectID is optional.
|
||||
// tenantID may also contain `multitenant` string. In this case the accountID and projectID
|
||||
// are obtained from vm_account_id and vm_project_id labels of the ingested samples.
|
||||
// - suffix contains arbitrary suffix.
|
||||
//
|
||||
|
@ -31,16 +29,18 @@ func ParsePath(path string) (*Path, error) {
|
|||
s := skipPrefixSlashes(path)
|
||||
n := strings.IndexByte(s, '/')
|
||||
if n < 0 {
|
||||
return nil, fmt.Errorf("cannot find {prefix} in %q; expecting /{prefix}/{authToken}/{suffix} format", path)
|
||||
return nil, fmt.Errorf("cannot find {prefix} in %q; expecting /{prefix}/{tenantID}/{suffix} format; "+
|
||||
"see https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format", path)
|
||||
}
|
||||
prefix := s[:n]
|
||||
|
||||
s = skipPrefixSlashes(s[n+1:])
|
||||
n = strings.IndexByte(s, '/')
|
||||
if n < 0 {
|
||||
return nil, fmt.Errorf("cannot find {authToken} in %q; expecting /{prefix}/{authToken}/{suffix} format", path)
|
||||
return nil, fmt.Errorf("cannot find {tenantID} in %q; expecting /{prefix}/{tenantID}/{suffix} format; "+
|
||||
"see https://docs.victoriametrics.com/Cluster-VictoriaMetrics.html#url-format", path)
|
||||
}
|
||||
authToken := s[:n]
|
||||
tenantID := s[:n]
|
||||
|
||||
s = skipPrefixSlashes(s[n+1:])
|
||||
|
||||
|
@ -50,7 +50,7 @@ func ParsePath(path string) (*Path, error) {
|
|||
|
||||
p := &Path{
|
||||
Prefix: prefix,
|
||||
AuthToken: authToken,
|
||||
AuthToken: tenantID,
|
||||
Suffix: suffix,
|
||||
}
|
||||
return p, nil
|
||||
|
|
Loading…
Reference in a new issue