Skip to content

Commit d43b8d3

Browse files
committed
feat: add info handler on sharedapi
1 parent 23e7cd4 commit d43b8d3

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

sharedapi/go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/formancehq/go-libs/sharedapi
2+
3+
go 1.19

sharedapi/handler_info.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package sharedapi
2+
3+
import (
4+
"encoding/json"
5+
"net/http"
6+
)
7+
8+
type ServiceInfo struct {
9+
Version string `json:"version"`
10+
}
11+
12+
func InfoHandler(info ServiceInfo) http.HandlerFunc {
13+
return func(w http.ResponseWriter, r *http.Request) {
14+
if err := json.NewEncoder(w).Encode(info); err != nil {
15+
panic(err)
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)