mirror of
https://github.com/Macrame-App/Macrame
synced 2025-12-29 07:19:26 +00:00
Major Update, registration and authentication of devices works now.
This is the first iteration of the registration of devices and authentication for a couple of endpoints. This needs to be refactored, the code is a bit of a mess. Also because of testing some endpoints are available for remotes that shouldn't be.
This commit is contained in:
parent
193ce6c8f1
commit
b598a090bc
12 changed files with 308 additions and 49 deletions
|
|
@ -48,7 +48,15 @@ func ApiGet(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
func ApiPost(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if !helper.EndpointAccess(w, r) {
|
||||
access, data := helper.EndpointAccess(w, r)
|
||||
|
||||
if !access {
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("api post", data == "")
|
||||
if data != "" {
|
||||
ApiAuth(data, w, r)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +68,7 @@ func ApiPost(w http.ResponseWriter, r *http.Request) {
|
|||
case "/macro/delete":
|
||||
DeleteMacro(w, r)
|
||||
case "/macro/play":
|
||||
PlayMacro(w, r)
|
||||
PlayMacro("", w, r)
|
||||
case "/device/list":
|
||||
DeviceList(w, r)
|
||||
case "/device/access/check":
|
||||
|
|
@ -71,10 +79,21 @@ func ApiPost(w http.ResponseWriter, r *http.Request) {
|
|||
PingLink(w, r)
|
||||
case "/device/link/start":
|
||||
StartLink(w, r)
|
||||
case "/device/link/poll":
|
||||
PollLink(w, r)
|
||||
case "/device/link/remove":
|
||||
RemoveLink("", w, r)
|
||||
case "/device/handshake":
|
||||
Handshake(w, r)
|
||||
case "/poll/remote":
|
||||
PollRemote(w, r)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func ApiAuth(data string, w http.ResponseWriter, r *http.Request) {
|
||||
log.Println("apiauth", data != "")
|
||||
switch r.URL.Path {
|
||||
case "/macro/play":
|
||||
PlayMacro(data, w, r)
|
||||
case "/device/link/remove":
|
||||
RemoveLink(data, w, r)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue