Documentation
¶
Index ¶
- type JSONResponse
- type Tools
- func (t *Tools) ErrorJSON(w http.ResponseWriter, err error, status ...int) error
- func (t *Tools) RandomString(n int) string
- func (t *Tools) ReadJSON(w http.ResponseWriter, r *http.Request, data any) error
- func (t *Tools) Slugify(s string) (string, error)
- func (t *Tools) WriteJSON(w http.ResponseWriter, status int, data interface{}, headers ...http.Header) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONResponse ¶
type Tools ¶
type Tools struct {
MaxJSONSize int // maximum size of JSON file we'll process
AllowUnknownFields bool // if set to true, allow unknown fields in JSON
}
func (*Tools) ErrorJSON ¶
ErrorJSON takes an error, and optionally a response status code, and generates and sends a JSON error response.
func (*Tools) RandomString ¶
RandomString returns a random string of letters of length n, using characters specified in randomStringSource.
func (*Tools) ReadJSON ¶
ReadJSON tries to read the body of a request and converts it from JSON to a variable. The third parameter, data, is expected to be a pointer, so that we can read data into it.
Click to show internal directories.
Click to hide internal directories.