This commit is contained in:
Evan Reichard 2021-01-19 16:26:10 -05:00
parent 45d7adbd8b
commit d5d985d682
7 changed files with 29 additions and 4 deletions

Binary file not shown.

BIN
cmd/main Executable file

Binary file not shown.

View File

@ -192,7 +192,7 @@ func deriveRequestedDevice(r *http.Request) models.Device {
} }
// Derive Value // Derive Value
val := trimQuotes(strings.ToLower(strings.TrimSpace(splitItem[1]))) val := trimQuotes(strings.TrimSpace(splitItem[1]))
if key == "deviceuuid" { if key == "deviceuuid" {
parsedDeviceUUID, err := uuid.Parse(val) parsedDeviceUUID, err := uuid.Parse(val)
if err != nil { if err != nil {

View File

@ -5,5 +5,22 @@ import (
) )
func (api *API) mediaItemsHandler(w http.ResponseWriter, r *http.Request) { func (api *API) mediaItemsHandler(w http.ResponseWriter, r *http.Request) {
if r.Method == http.MethodPost {
// CREATE
} else if r.Method == http.MethodPut {
// UPDATE / REPLACE
} else if r.Method == http.MethodPatch {
// UPDATE / MODIFY
} else if r.Method == http.MethodDelete {
// DELETE
} else if r.Method == http.MethodGet {
// GET
} else {
errorJSON(w, "Method is not supported.", http.StatusMethodNotAllowed)
return
}
}
func (api *API) createMediaitem() {
} }

View File

@ -1,9 +1,8 @@
package api package api
import ( import (
"net/http"
"os" "os"
"net/http"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
@ -31,14 +30,21 @@ func (api *API) authMiddleware(next http.Handler) http.HandlerFunc {
} }
// Validate JWT Tokens // Validate JWT Tokens
// accessToken, accessOK := api.Auth.ValidateJWTAccessToken(accessCookie.Value)
_, accessOK := api.Auth.ValidateJWTAccessToken(accessCookie.Value) _, accessOK := api.Auth.ValidateJWTAccessToken(accessCookie.Value)
if accessOK { if accessOK {
// Acquire UserID and DeviceID
// uid, _ := accessToken.Get("sub")
// did, _ := accessToken.Get("did")
// Set context uid & did
next.ServeHTTP(w, r) next.ServeHTTP(w, r)
} else { } else {
w.WriteHeader(http.StatusUnauthorized) w.WriteHeader(http.StatusUnauthorized)
} }
}) })
} }
func (api *API) logMiddleware(h http.Handler) http.Handler { func (api *API) logMiddleware(h http.Handler) http.Handler {

View File

@ -0,0 +1 @@
package db

View File

@ -0,0 +1 @@
package db