Skip to content

Commit

Permalink
api: added validation endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
yusing committed Jan 26, 2025
1 parent 7ec42dc commit 83ea19d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/api/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func NewHandler(cfg config.ConfigInstance) http.Handler {
mux.HandleFunc("GET", "/v1/list/{what}/{which}", auth.RequireAuth(useCfg(cfg, v1.List)))
mux.HandleFunc("GET", "/v1/file/{type}/{filename}", auth.RequireAuth(v1.GetFileContent))
mux.HandleFunc("POST,PUT", "/v1/file/{type}/{filename}", auth.RequireAuth(v1.SetFileContent))
mux.HandleFunc("POST", "/v1/file/validate/{type}", auth.RequireAuth(v1.ValidateFile))
mux.HandleFunc("GET", "/v1/schema/{filename...}", v1.GetSchemaFile)
mux.HandleFunc("GET", "/v1/stats", useCfg(cfg, v1.Stats))
mux.HandleFunc("GET", "/v1/stats/ws", useCfg(cfg, v1.StatsWS))
Expand Down
12 changes: 11 additions & 1 deletion internal/utils/strutils/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,17 @@ func Title(s string) string {
}

func ToLowerNoSnake(s string) string {
return strings.ToLower(strings.ReplaceAll(s, "_", ""))
var buf strings.Builder
for _, r := range s {
if r == '_' {
continue
}
if r >= 'A' && r <= 'Z' {
r += 'a' - 'A'
}
buf.WriteRune(r)
}
return buf.String()
}

//nolint:intrange
Expand Down

0 comments on commit 83ea19d

Please sign in to comment.