Small improvements
This commit is contained in:
1
backend/.gitignore
vendored
Normal file
1
backend/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
tmp
|
||||
@@ -27,14 +27,6 @@ type Claims struct {
|
||||
}
|
||||
|
||||
func HandleLogin(w http.ResponseWriter, r *http.Request) {
|
||||
// if r.Method != http.MethodPost {
|
||||
// core.JSONError{
|
||||
// Status: core.Error,
|
||||
// Message: "Method is not allowed",
|
||||
// }.Respond(w, http.StatusMethodNotAllowed)
|
||||
// return
|
||||
// }
|
||||
|
||||
if r.Body == nil {
|
||||
core.JSONError{
|
||||
Status: core.Error,
|
||||
|
||||
@@ -8,14 +8,6 @@ import (
|
||||
)
|
||||
|
||||
func HandleDeleteUser(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodDelete {
|
||||
core.JSONError{
|
||||
Status: core.Error,
|
||||
Message: "Method is not allowed.",
|
||||
}.Respond(w, http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
uuid := r.PathValue("user_uuid")
|
||||
_, err := core.DB.NewDelete().
|
||||
Model((*core.User)(nil)).
|
||||
|
||||
@@ -8,14 +8,6 @@ import (
|
||||
)
|
||||
|
||||
func HandleGetUser(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
core.JSONError{
|
||||
Status: core.Error,
|
||||
Message: "Method is not allowed.",
|
||||
}.Respond(w, http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
uuid := r.PathValue("user_uuid")
|
||||
var user core.User
|
||||
count, err := core.DB.NewSelect().
|
||||
|
||||
@@ -9,14 +9,6 @@ import (
|
||||
)
|
||||
|
||||
func HandleGetUsers(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
core.JSONError{
|
||||
Status: core.Error,
|
||||
Message: "Method is not allowed.",
|
||||
}.Respond(w, http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
var users []core.User
|
||||
count, err := core.DB.NewSelect().
|
||||
Model(&users).
|
||||
|
||||
@@ -11,15 +11,6 @@ import (
|
||||
)
|
||||
|
||||
func HandleCreateUser(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
if r.Method != http.MethodPost {
|
||||
core.JSONError{
|
||||
Status: core.Error,
|
||||
Message: "This method is not allowed",
|
||||
}.Respond(w, http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
core.JSONError{
|
||||
|
||||
@@ -23,14 +23,6 @@ type UpdateUserArgs struct {
|
||||
}
|
||||
|
||||
func HandleUpdateUser(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPatch {
|
||||
core.JSONError{
|
||||
Status: core.Error,
|
||||
Message: "Method is not allowed.",
|
||||
}.Respond(w, http.StatusMethodNotAllowed)
|
||||
return
|
||||
}
|
||||
|
||||
var updateArgs UpdateUserArgs
|
||||
body, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
@@ -94,4 +86,3 @@ func HandleUpdateUser(w http.ResponseWriter, r *http.Request) {
|
||||
Data: user,
|
||||
}.Respond(w, http.StatusOK)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user