Documentation ¶
Index ¶
- Variables
- func BadRequest(w http.ResponseWriter, v ...any)
- func Bytes(w http.ResponseWriter, bytes []byte)
- func CustomDecode(r io.Reader, v any, decoder func(r io.Reader, v any) error) error
- func Decode(r io.Reader, v any) error
- func ErrorCode(w http.ResponseWriter, status int, v ...any)
- func Forbidden(w http.ResponseWriter, v ...any)
- func Found(w http.ResponseWriter, r *http.Request, url string)
- func HookError(hook func(error) any)
- func InternalError(w http.ResponseWriter, v ...any)
- func JSON(w http.ResponseWriter, v any, status int)
- func NoContent(w http.ResponseWriter)
- func NotFound(w http.ResponseWriter, v ...any)
- func NotImplemented(w http.ResponseWriter, v ...any)
- func OK(w http.ResponseWriter, v any)
- func Redirect(w http.ResponseWriter, r *http.Request, url string, code int)
- func SetLog(l Log)
- func Str(w http.ResponseWriter, str string)
- func Success(w http.ResponseWriter)
- func Unauthorized(w http.ResponseWriter, v ...any)
- type KVLog
- type Log
- type Validator
Constants ¶
This section is empty.
Variables ¶
var DefaultDecoder = func(r io.Reader, v any) error { return json.NewDecoder(r).Decode(v) }
var InitLogger = SetLog
InitLogger initialization the log processing method Deprecated: SetLog instead.
Functions ¶
func BadRequest ¶
func BadRequest(w http.ResponseWriter, v ...any)
BadRequest writes the json-encoded error message to the response with a 400 bad request status code.
func Bytes ¶
func Bytes(w http.ResponseWriter, bytes []byte)
Bytes writes the Bytes message to the response.
func CustomDecode ¶
func ErrorCode ¶
func ErrorCode(w http.ResponseWriter, status int, v ...any)
ErrorCode writes the json-encoded error message to the response.
func Forbidden ¶
func Forbidden(w http.ResponseWriter, v ...any)
Forbidden writes the json-encoded error message to the response with a 403 forbidden status code.
func Found ¶
func Found(w http.ResponseWriter, r *http.Request, url string)
Found replies to the request with a redirect to url.
func InternalError ¶
func InternalError(w http.ResponseWriter, v ...any)
InternalError writes the json-encoded error message to the response with a 500 internal server error.
func JSON ¶
func JSON(w http.ResponseWriter, v any, status int)
JSON writes the json-encoded error message to the response with a 400 bad request status code.
func NotFound ¶
func NotFound(w http.ResponseWriter, v ...any)
NotFound writes the json-encoded error message to the response with a 404 not found status code.
func NotImplemented ¶
func NotImplemented(w http.ResponseWriter, v ...any)
NotImplemented writes the json-encoded error message to the response with a 501 not found status code.
func Str ¶
func Str(w http.ResponseWriter, str string)
Str writes the string message to the response.
func Unauthorized ¶
func Unauthorized(w http.ResponseWriter, v ...any)
Unauthorized writes the json-encoded error message to the response with a 401 unauthorized status code.