Chore: Query endpoint refactor (#41637)

Get rid of using legacydata.RequestHandler in HTTPServer, /api/tsdb/query and pkg/expr 
with the goal of deprecating /api/tsdb/query and remove it completely eventually. This is 
the first step of cleaning up the HTTP API query endpoint.

Co-authored-by: Marcus Efraimsson <marcus.efraimsson@gmail.com>
Co-authored-by: Alexander Emelin <frvzmb@gmail.com>
This commit is contained in:
Marcus Efraimsson
2021-11-29 14:21:54 +01:00
committed by GitHub
parent 6e8cc426d6
commit 8927a3ca20
10 changed files with 242 additions and 316 deletions

View File

@@ -6,6 +6,7 @@ import (
"regexp"
"strings"
"time"
"unicode"
)
// StringsFallback2 returns the first of two not empty strings.
@@ -108,3 +109,12 @@ func ToCamelCase(str string) string {
return strings.Join(finalParts, "")
}
func Capitalize(s string) string {
if len(s) == 0 {
return s
}
r := []rune(s)
r[0] = unicode.ToUpper(r[0])
return string(r)
}

View File

@@ -88,8 +88,20 @@ func TestToCamelCase(t *testing.T) {
"snake_case_string": "snakeCaseString",
"mixed-case_string": "mixedCaseString",
"alreadyCamelCase": "alreadyCamelCase",
"": "",
}
for input, expected := range tests {
assert.Equal(t, expected, ToCamelCase(input))
}
}
func TestCapitalize(t *testing.T) {
tests := map[string]string{
"properly capitalizes": "Properly capitalizes",
"Already capitalized": "Already capitalized",
"": "",
}
for input, expected := range tests {
assert.Equal(t, expected, Capitalize(input))
}
}