feat: get handlers return object slices
This commit is contained in:
@ -8,6 +8,6 @@ import (
|
||||
|
||||
type GoFormatter struct{}
|
||||
|
||||
func (f *GoFormatter) Format(object any) (io.Reader, error) {
|
||||
return strings.NewReader(fmt.Sprintf("%#v", object)), nil
|
||||
func (f *GoFormatter) Format(objects []any) (io.Reader, error) {
|
||||
return strings.NewReader(fmt.Sprintf("%#v", objects)), nil
|
||||
}
|
||||
|
||||
@ -8,8 +8,8 @@ import (
|
||||
|
||||
type JsonFormatter struct{}
|
||||
|
||||
func (f *JsonFormatter) Format(object any) (io.Reader, error) {
|
||||
func (f *JsonFormatter) Format(objects []any) (io.Reader, error) {
|
||||
var buffer = make([]byte, 0, 1024)
|
||||
outputBuffer := bytes.NewBuffer(buffer)
|
||||
return outputBuffer, json.NewEncoder(outputBuffer).Encode(object)
|
||||
return outputBuffer, json.NewEncoder(outputBuffer).Encode(objects)
|
||||
}
|
||||
|
||||
@ -9,8 +9,8 @@ import (
|
||||
|
||||
type YamlFormatter struct{}
|
||||
|
||||
func (f *YamlFormatter) Format(object any) (io.Reader, error) {
|
||||
buffer, err := yaml.Marshal(object)
|
||||
func (f *YamlFormatter) Format(objects []any) (io.Reader, error) {
|
||||
buffer, err := yaml.Marshal(objects)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user