40 lines
1023 B
Go
40 lines
1023 B
Go
package routes
|
|
|
|
import (
|
|
"net/http"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func (ctx *ImaginiContext) usersHandler(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 {
|
|
JSONError(w, "Method is not supported.", http.StatusMethodNotAllowed)
|
|
return
|
|
}
|
|
}
|
|
|
|
func (ctx *ImaginiContext) meHandler(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet {
|
|
JSONError(w, "Method is not supported.", http.StatusMethodNotAllowed)
|
|
return
|
|
}
|
|
|
|
// Get Authenticated User & Return Object
|
|
authCookie, err := r.Cookie("Token")
|
|
if err != nil {
|
|
log.Error("[routes] ", err)
|
|
return
|
|
}
|
|
|
|
log.Info("[routes] INFO: ", authCookie)
|
|
}
|