From d5e618a694ed3b252f7dc1bc23c34cc9c0b712af Mon Sep 17 00:00:00 2001 From: Rodrigo Broggi Date: Sun, 21 Jul 2024 15:08:56 +0200 Subject: [PATCH] example and doc update --- example/server/main.go | 6 ++++-- example/server/server.go | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/example/server/main.go b/example/server/main.go index 7d7f29b..ddbe403 100644 --- a/example/server/main.go +++ b/example/server/main.go @@ -19,8 +19,9 @@ import ( ) type conf struct { - Name string `json:"name" default:"john"` - Age int `json:"age"` + Name string `json:"name" default:"john"` + Age int `json:"age"` + Friends []string `json:"friends" default:"[\"mark\",\"tom\",\"jack\"]"` } func (c *conf) Update(new config.Config) error { @@ -30,6 +31,7 @@ func (c *conf) Update(new config.Config) error { } c.Name = newCfg.Name c.Age = newCfg.Age + c.Friends = newCfg.Friends return nil } diff --git a/example/server/server.go b/example/server/server.go index c319512..3ef8b9b 100644 --- a/example/server/server.go +++ b/example/server/server.go @@ -90,14 +90,14 @@ func (s *server) listConfigsHandler(w http.ResponseWriter, r *http.Request) { if err != nil { w.WriteHeader(http.StatusBadRequest) fmt.Fprintf(w, "fromVersion must be a non-negative integer") - s.lgr.With("error", err).ErrorContext(r.Context(), "parsing from-version string %s", fromVersionStr) + s.lgr.With("error", err).ErrorContext(r.Context(), fmt.Sprintf("parsing from-version string %s", fromVersionStr)) return } toVersion, err := strconv.ParseUint(toVersionStr, 0, 32) if err != nil { - s.lgr.With("error", err).ErrorContext(r.Context(), "parsing to-version string %s", toVersionStr) - fmt.Fprintf(w, "toVersion must be a non-negative integer") w.WriteHeader(http.StatusBadRequest) + fmt.Fprintf(w, "toVersion must be a non-negative integer") + s.lgr.With("error", err).ErrorContext(r.Context(), fmt.Sprintf("parsing to-version string %s", toVersionStr)) return } versions, err := s.repo.ListVersionedConfigs(r.Context(), config.ListVersionedConfigsQuery{