mirror of
https://github.com/hanzoai/o11y.git
synced 2026-10-15 12:58:33 +00:00
Full rebrand of the SigNoz observability platform: - Go module: github.com/SigNoz/signoz → github.com/hanzoai/o11y - Frontend: @signozhq/* → @hanzo/o11y-*, posthog-js → @hanzo/insights - Docker: signoz/* → ghcr.io/hanzoai/o11y* - ClickHouse → Hanzo Datastore (hanzoai/datastore) - Env vars: SIGNOZ_* → HANZO_* - DB tables: signoz_* → o11y_* - All branding, URLs, docs updated - 2172 files changed
49 lines
920 B
Go
49 lines
920 B
Go
package config
|
|
|
|
import (
|
|
"regexp"
|
|
|
|
"github.com/hanzoai/o11y/pkg/errors"
|
|
)
|
|
|
|
var (
|
|
// uriRegex is a regex that matches the URI format. It complies with the URI definition defined at https://datatracker.ietf.org/doc/html/rfc3986.
|
|
// The format is "<scheme>:<value>".
|
|
uriRegex = regexp.MustCompile(`(?s:^(?P<Scheme>[A-Za-z][A-Za-z0-9+.-]+):(?P<Value>.*)$)`)
|
|
)
|
|
|
|
type Uri struct {
|
|
scheme string
|
|
value string
|
|
}
|
|
|
|
func NewUri(input string) (Uri, error) {
|
|
submatches := uriRegex.FindStringSubmatch(input)
|
|
|
|
if len(submatches) != 3 {
|
|
return Uri{}, errors.NewInvalidInputf(errors.CodeInvalidInput, "invalid uri: %q", input)
|
|
}
|
|
|
|
return Uri{
|
|
scheme: submatches[1],
|
|
value: submatches[2],
|
|
}, nil
|
|
}
|
|
|
|
func MustNewUri(input string) Uri {
|
|
uri, err := NewUri(input)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
return uri
|
|
}
|
|
|
|
func (uri Uri) Scheme() string {
|
|
return uri.scheme
|
|
}
|
|
|
|
func (uri Uri) Value() string {
|
|
return uri.value
|
|
}
|