mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Add comment endpoint
This commit is contained in:
parent
0c93893627
commit
cee3410532
3 changed files with 354 additions and 0 deletions
12
utils.go
12
utils.go
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue