Skip to content

Commit

Permalink
example and doc update
Browse files Browse the repository at this point in the history
  • Loading branch information
rbroggi committed Jul 21, 2024
1 parent 23ad76d commit d5e618a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions example/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions example/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit d5e618a

Please sign in to comment.