Versions in this module Expand all Collapse all v1 v1.0.1 Oct 3, 2024 v1.0.0 Oct 3, 2024 Changes in this version + var EnableRateLimiting bool + func CacheImmutable(w http.ResponseWriter) + func CacheNever(w http.ResponseWriter) + func CacheSeconds(w http.ResponseWriter, seconds int) + func Check(err error) + func CheckClient(err error) + func CheckLogged(l logs.Log, err error) + func Do(req *http.Request) (*http.Response, error) + func EncodeQuery(kv map[string]string) string + func FailedRequestSummary(resp *http.Response, err error) string + func FailedRequestSummaryEx(resp *http.Response, err error, maxBodyLen int) string + func FetchJSON(req *http.Request, output any) error + func Handle(log logs.Log, router *httprouter.Router, method, path string, ...) + func IsNotModified(w http.ResponseWriter, r *http.Request, modifiedAt time.Time) bool + func IsNotModifiedEx(w http.ResponseWriter, r *http.Request, modifiedAt time.Time, ...) bool + func Panic(code int, message string) + func PanicBadRequest() + func PanicBadRequestf(format string, args ...interface{}) + func PanicForbidden() + func PanicForbiddenf(format string, args ...interface{}) + func PanicNoContent() + func PanicNotFound() + func PanicServerError(msg string) + func PanicServerErrorf(format string, args ...interface{}) + func PanicUnauthorized() + func ParseID(s string) int64 + func QueryFloat64(r *http.Request, key string) float64 + func QueryInt(r *http.Request, key string) int + func QueryInt64(r *http.Request, key string) int64 + func QueryIntArray[T constraints.Integer](r *http.Request, key string) []T + func QueryValue(r *http.Request, key string) string + func QueryValueEx(r *http.Request, s string) (string, bool) + func RateLimit(groupName string, maxPerSecond float64, w http.ResponseWriter, r *http.Request) + func ReadIDList(r *http.Request) []int64 + func ReadJSON(w http.ResponseWriter, r *http.Request, obj interface{}, maxBodyBytes int64) + func ReadLimited(w http.ResponseWriter, r *http.Request, maxBodyBytes int64) []byte + func ReadString(w http.ResponseWriter, r *http.Request, maxBodyBytes int64) string + func RequiredQueryInt(r *http.Request, key string) int + func RequiredQueryInt64(r *http.Request, key string) int64 + func RequiredQueryValue(r *http.Request, key string) string + func RunProtected(log logs.Log, w http.ResponseWriter, r *http.Request, handler func()) + func SendError(w http.ResponseWriter, message string, code int) + func SendFile(w http.ResponseWriter, r *http.Request, filename, contentType string) + func SendFileDownload(w http.ResponseWriter, filename, contentType string, content []byte) + func SendFmt(w http.ResponseWriter, any interface{}) + func SendID(w http.ResponseWriter, id int64) + func SendInt64(w http.ResponseWriter, id int64) + func SendJSON(w http.ResponseWriter, obj interface{}) + func SendJSONBool(w http.ResponseWriter, v bool) + func SendJSONID(w http.ResponseWriter, id int64) + func SendJSONOpt(w http.ResponseWriter, obj interface{}, pretty bool) + func SendJSONRaw(w http.ResponseWriter, raw any) + func SendOK(w http.ResponseWriter) + func SendTempFile(w http.ResponseWriter, r *http.Request, filename, contentType string) + func SendText(w http.ResponseWriter, text string) + func SplitIDList(idList string) []int64 + func TryMultipleTimes(maxAttempts int, action func() error) error + type HTTPError struct + Code int + Message string + func BadRequest() HTTPError + func BadRequestf(format string, args ...interface{}) HTTPError + func Error(code int, message string) HTTPError + func Forbidden() HTTPError + func Forbiddenf(format string, args ...interface{}) HTTPError + func NoContent() HTTPError + func NotFound() HTTPError + func ServerError(msg string) HTTPError + func ServerErrorf(format string, args ...interface{}) HTTPError + func Unauthorized() HTTPError + func (e HTTPError) Error() string