forked from luismanolo/rpi_kiosk_webservice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
password.go
38 lines (34 loc) · 898 Bytes
/
password.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
36
37
38
package main
import (
"encoding/json"
"github.com/julienschmidt/httprouter"
"net/http"
)
type PasswordInput struct {
Password string
}
type PasswordOutput struct {
Result string
}
func checkPassword(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
var data PasswordInput
err := json.NewDecoder(r.Body).Decode(&data)
if err != nil {
var responseData PasswordOutput
responseData.Result = "nok"
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(responseData)
return
}
if data.Password == "3600" {
var responseData PasswordOutput
responseData.Result = "ok"
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(responseData)
return
}
var responseData PasswordOutput
responseData.Result = "nok"
w.Header().Set("Content-Type", "application/json")
_ = json.NewEncoder(w).Encode(responseData)
}