Add comment endpoint

This commit is contained in:
bytedream 2022-06-19 14:43:46 +02:00
parent 0c93893627
commit cee3410532
3 changed files with 354 additions and 0 deletions

View file

@ -1,6 +1,7 @@
package crunchyroll
import (
"bytes"
"encoding/json"
"fmt"
"net/url"
@ -70,3 +71,14 @@ func encodeStructToQueryValues(s interface{}) (string, error) {
return values.Encode(), nil
}
func structDefaults[T any](defaultStruct T, customStruct T) (T, error) {
rawDefaultStruct, err := json.Marshal(defaultStruct)
if err != nil {
return *new(T), err
}
if err = json.NewDecoder(bytes.NewBuffer(rawDefaultStruct)).Decode(&customStruct); err != nil {
return *new(T), err
}
return customStruct, nil
}