Add funcs for TextVariant.
This commit is contained in:
parent
783a2dedfa
commit
a173059aef
|
@ -98,6 +98,27 @@ type TextVariant struct {
|
|||
Message string `json:"message"`
|
||||
}
|
||||
|
||||
func FindTextVariantByLang(textVariants []*TextVariant, lang int) *TextVariant {
|
||||
for _, textVariant := range textVariants {
|
||||
if textVariant.Lang == lang {
|
||||
return textVariant
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func ReadTextVariantsFromRequest(request *http.Request, textVariants *[]*TextVariant) error {
|
||||
b, err := io.ReadAll(request.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if b == nil {
|
||||
return errors.New("Can not read text variants. Request body bytes is nil.")
|
||||
}
|
||||
|
||||
return json.Unmarshal(b, textVariants)
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
type PushRequest struct {
|
||||
|
|
Loading…
Reference in New Issue