Fixed lint issues and missing documentation

This commit is contained in:
bwilliams committed 2026-10-13 12:21:32 +01:00
1 parent 7fd321df97
commit 6e6dec68c0
34 files changed
+346 -156

No files matched your search

+6 -1
View File
@@ -22,6 +22,7 @@ const (
BasePath = "/api/1.0/ocdsReleasePackages"
)
// server serves release packages from a Store; see NewHandler.
type server struct {
store *Store
baseURL string
@@ -39,6 +40,8 @@ func NewHandler(
return (&server{store: store, baseURL: baseURL, loc: loc}).handle
}
// encodeCursor makes the opaque cursor for a next link that resumes at store
// position i.
func encodeCursor(i int) string {
return base64.RawURLEncoding.EncodeToString([]byte("idx:" + strconv.Itoa(i)))
}
@@ -62,7 +65,7 @@ func decodeCursor(c string) (int, error) {
func badRequest(w http.ResponseWriter, msg string) {
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusBadRequest)
json.NewEncoder(w).Encode(map[string]string{"error": msg})
_ = json.NewEncoder(w).Encode(map[string]string{"error": msg}) // the client has gone
}
// parseTime reads a query timestamp. Values without an offset (the documented
@@ -93,6 +96,8 @@ type pageQuery struct {
limit int
}
// handle answers a GET for a page of releases as an OCDS release package,
// with a links.next when more releases match.
func (s *server) handle(w http.ResponseWriter, req *http.Request) {
if req.Method != http.MethodGet {
w.WriteHeader(http.StatusMethodNotAllowed)