code cleanup
This commit is contained in:
@@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
//goland:noinspection SpellCheckingInspection
|
//goland:noinspection SpellCheckingInspection
|
||||||
var DICT = "ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789"
|
var DICT = "ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789"
|
||||||
var sharecodeRexEx = regexp.MustCompile("^CSGO(?:-?[\\w]{5}){5}$")
|
var sharecodeRexEx = regexp.MustCompile("^CSGO(?:-?\\w{5}){5}$")
|
||||||
|
|
||||||
func DecodeSharecode(code string) (uint64, uint64, uint16, error) {
|
func DecodeSharecode(code string) (uint64, uint64, uint16, error) {
|
||||||
if !sharecodeRexEx.MatchString(code) {
|
if !sharecodeRexEx.MatchString(code) {
|
||||||
|
@@ -244,21 +244,6 @@ var (
|
|||||||
AuthCodeRegEx = regexp.MustCompile(`^[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{4}-[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{5}-[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{4}$`)
|
AuthCodeRegEx = regexp.MustCompile(`^[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{4}-[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{5}-[ABCDEFGHJKLMNOPQRSTUVWXYZ23456789]{4}$`)
|
||||||
)
|
)
|
||||||
|
|
||||||
func SendJSON(data interface{}, w http.ResponseWriter) error {
|
|
||||||
w.Header().Set("content-type", "application/json")
|
|
||||||
playerJson, err := json.Marshal(data)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
_, err = w.Write(playerJson)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetMetaStats(dbPlayer *ent.Player) (*MetaStatsResponse, error) {
|
func GetMetaStats(dbPlayer *ent.Player) (*MetaStatsResponse, error) {
|
||||||
mResponse := new(MetaStatsResponse)
|
mResponse := new(MetaStatsResponse)
|
||||||
mResponse.Player = &PlayerResponse{SteamID64: dbPlayer.ID}
|
mResponse.Player = &PlayerResponse{SteamID64: dbPlayer.ID}
|
||||||
@@ -711,7 +696,9 @@ func TranslateWithDeepL(text string, language string, baseURL string, apiKey str
|
|||||||
return "", "", fmt.Errorf("deepl response %d", dlResp.StatusCode)
|
return "", "", fmt.Errorf("deepl response %d", dlResp.StatusCode)
|
||||||
} else {
|
} else {
|
||||||
respBytes, err := io.ReadAll(dlResp.Body)
|
respBytes, err := io.ReadAll(dlResp.Body)
|
||||||
defer dlResp.Body.Close()
|
defer func(Body io.ReadCloser) {
|
||||||
|
_ = Body.Close()
|
||||||
|
}(dlResp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", fmt.Errorf("error reading deepl response: %w", err)
|
return "", "", fmt.Errorf("error reading deepl response: %w", err)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user