Skip to content

Commit

Permalink
add http package
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepeterson committed Jul 23, 2024
1 parent a5c7286 commit f492583
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions http/http.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Package http includes handlers and utilties.
package http

import "net/http"

// JSONVersionHandler returns a simple JSON response from a version string.
// The returned JSON is in the form of `{"version":"v0.0.1"}`.
func JSONVersionHandler(version string) http.HandlerFunc {
bodyBytes := []byte(`{"version":"` + version + `"}`)
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Write(bodyBytes)
}
}

0 comments on commit f492583

Please sign in to comment.