photoprism/internal/form/json.go
Michael Mayer 6abbc39017 Security: Add http rate limiter and auto tls mode #98
Signed-off-by: Michael Mayer <michael@photoprism.app>
2022-10-11 22:44:11 +02:00

19 lines
388 B
Go

package form
import (
"encoding/json"
"io"
"strings"
)
// AsJson returns the form data as a JSON string or an empty string in case of error.
func AsJson(frm interface{}) string {
s, _ := json.Marshal(frm)
return string(s)
}
// AsReader returns the form data as io.Reader, e.g. for use in tests.
func AsReader(frm interface{}) io.Reader {
return strings.NewReader(AsJson(frm))
}