Remove get prefix from certain function names

oauth2
maru 2024-04-25 03:50:35 -04:00
parent 768900d885
commit 849bc601f0
No known key found for this signature in database
GPG Key ID: 37689350E9CD0F0D
2 changed files with 9 additions and 9 deletions

View File

@ -38,7 +38,7 @@ func Init(mux *http.ServeMux) {
mux.HandleFunc("/daily/rankingpagecount", handleDailyRankingPageCount) mux.HandleFunc("/daily/rankingpagecount", handleDailyRankingPageCount)
} }
func getTokenFromRequest(r *http.Request) ([]byte, error) { func tokenFromRequest(r *http.Request) ([]byte, error) {
if r.Header.Get("Authorization") == "" { if r.Header.Get("Authorization") == "" {
return nil, fmt.Errorf("missing token") return nil, fmt.Errorf("missing token")
} }
@ -55,8 +55,8 @@ func getTokenFromRequest(r *http.Request) ([]byte, error) {
return token, nil return token, nil
} }
func getUsernameFromRequest(r *http.Request) (string, error) { func usernameFromRequest(r *http.Request) (string, error) {
token, err := getTokenFromRequest(r) token, err := tokenFromRequest(r)
if err != nil { if err != nil {
return "", err return "", err
} }
@ -69,8 +69,8 @@ func getUsernameFromRequest(r *http.Request) (string, error) {
return username, nil return username, nil
} }
func getUUIDFromRequest(r *http.Request) ([]byte, error) { func uuidFromRequest(r *http.Request) ([]byte, error) {
token, err := getTokenFromRequest(r) token, err := tokenFromRequest(r)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -23,13 +23,13 @@ import (
// account // account
func handleAccountInfo(w http.ResponseWriter, r *http.Request) { func handleAccountInfo(w http.ResponseWriter, r *http.Request) {
username, err := getUsernameFromRequest(r) username, err := usernameFromRequest(r)
if err != nil { if err != nil {
httpError(w, r, err, http.StatusBadRequest) httpError(w, r, err, http.StatusBadRequest)
return return
} }
uuid, err := getUUIDFromRequest(r) // lazy uuid, err := uuidFromRequest(r) // lazy
if err != nil { if err != nil {
httpError(w, r, err, http.StatusBadRequest) httpError(w, r, err, http.StatusBadRequest)
return return
@ -128,7 +128,7 @@ func handleGameClassicSessionCount(w http.ResponseWriter, r *http.Request) {
} }
func handleSaveData(w http.ResponseWriter, r *http.Request) { func handleSaveData(w http.ResponseWriter, r *http.Request) {
uuid, err := getUUIDFromRequest(r) uuid, err := uuidFromRequest(r)
if err != nil { if err != nil {
httpError(w, r, err, http.StatusBadRequest) httpError(w, r, err, http.StatusBadRequest)
return return
@ -178,7 +178,7 @@ func handleSaveData(w http.ResponseWriter, r *http.Request) {
} }
var token []byte var token []byte
token, err = getTokenFromRequest(r) token, err = tokenFromRequest(r)
if err != nil { if err != nil {
httpError(w, r, err, http.StatusBadRequest) httpError(w, r, err, http.StatusBadRequest)
return return