Move httpError to common.go

pull/4/head
maru 7 months ago
parent fa5dcb0052
commit 7e3ba249df
No known key found for this signature in database
GPG Key ID: 37689350E9CD0F0D

@ -3,6 +3,7 @@ package api
import ( import (
"encoding/base64" "encoding/base64"
"fmt" "fmt"
"log"
"net/http" "net/http"
"github.com/pagefaultgames/pokerogue-server/api/account" "github.com/pagefaultgames/pokerogue-server/api/account"
@ -81,3 +82,8 @@ func getUUIDFromRequest(r *http.Request) ([]byte, error) {
return uuid, nil return uuid, nil
} }
func httpError(w http.ResponseWriter, r *http.Request, err error, code int) {
log.Printf("%s: %s\n", r.URL.Path, err)
http.Error(w, err.Error(), code)
}

@ -4,7 +4,6 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"log"
"net/http" "net/http"
"strconv" "strconv"
@ -21,11 +20,6 @@ import (
Handlers should not return serialized JSON, instead return the struct itself. Handlers should not return serialized JSON, instead return the struct itself.
*/ */
func httpError(w http.ResponseWriter, r *http.Request, err error, code int) {
log.Printf("%s: %s\n", r.URL.Path, err)
http.Error(w, err.Error(), code)
}
// account // account
func handleAccountInfo(w http.ResponseWriter, r *http.Request) { func handleAccountInfo(w http.ResponseWriter, r *http.Request) {

Loading…
Cancel
Save