This repository has been archived on 2023-11-13. You can view files and clone it, but cannot push or open issues or pull requests.
imagini/internal/api/users.go

31 lines
788 B
Go
Raw Normal View History

2021-01-16 22:00:17 +00:00
package api
2021-01-06 19:36:09 +00:00
import (
"net/http"
2021-01-12 04:48:32 +00:00
log "github.com/sirupsen/logrus"
2021-01-06 19:36:09 +00:00
)
2021-01-16 22:00:17 +00:00
func (api *API) usersHandler(w http.ResponseWriter, r *http.Request) {
2021-01-12 04:48:32 +00:00
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 {
2021-01-16 22:00:17 +00:00
errorJSON(w, "Method is not supported.", http.StatusMethodNotAllowed)
2021-01-12 04:48:32 +00:00
return
}
2021-01-10 00:44:02 +00:00
}
2021-01-16 22:00:17 +00:00
func (api *API) meHandler(w http.ResponseWriter, r *http.Request) {
2021-01-12 04:48:32 +00:00
if r.Method != http.MethodGet {
2021-01-16 22:00:17 +00:00
errorJSON(w, "Method is not supported.", http.StatusMethodNotAllowed)
2021-01-12 04:48:32 +00:00
return
}
2021-01-06 19:36:09 +00:00
}