-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.go
35 lines (28 loc) · 915 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package main
import (
"encoding/json"
"log"
"net/http"
"github.com/ministryofjustice/opg-go-common/env"
)
func main() {
port := env.Get("PORT", "8080")
http.HandleFunc("/v2/notifications", func(w http.ResponseWriter, r *http.Request) {
json.NewEncoder(w).Encode(map[string]any{"notifications": []any{}})
})
http.HandleFunc("/v2/notifications/email", func(w http.ResponseWriter, r *http.Request) {
var v map[string]interface{}
json.NewDecoder(r.Body).Decode(&v)
log.Println("email:", v)
json.NewEncoder(w).Encode(map[string]string{"id": "an-email-id"})
})
http.HandleFunc("/v2/notifications/sms", func(w http.ResponseWriter, r *http.Request) {
var v map[string]interface{}
json.NewDecoder(r.Body).Decode(&v)
log.Println("sms:", v)
json.NewEncoder(w).Encode(map[string]string{"id": "an-sms-id"})
})
if err := http.ListenAndServe(":"+port, nil); err != nil {
log.Fatal(err)
}
}