JSON API (#28)

Co-authored-by: Raphael <raphael.schleithoff@tum.de>
Co-authored-by: Raphael <raphjaph@protonmail.com>
This commit is contained in:
Raphael
2021-10-27 11:48:21 +02:00
committed by GitHub
parent 3102708352
commit a8fd253bc3
4 changed files with 221 additions and 12 deletions

11
main.go
View File

@@ -95,6 +95,17 @@ func main() {
},
)
api := router.PathPrefix("/api/v1").Subrouter()
api.Use(authenticate)
// unauthenticated
api.HandleFunc("/claim", ClaimAddress).Methods("POST")
// authenticated routes; X-Pin in header or in json request body
api.HandleFunc("/users/{name}", GetUser).Methods("GET")
api.HandleFunc("/users/{name}", UpdateUser).Methods("PUT")
api.HandleFunc("/users/{name}", DeleteUser).Methods("DELETE")
srv := &http.Server{
Handler: router,
Addr: s.Host + ":" + s.Port,