http
v0.0.4
Documentation
pkg.go.dev ↗Functions
ErrorToAPIStatus
func ErrorToAPIStatus(err error) *metav1.Status
ErrorToAPIStatus converts an error to an metav1.Status object.
NewAlreadyExists
func NewAlreadyExists(err error, message ...string) *kerr.StatusError
NewAlreadyExists returns an error indicating the item requested already exists.
NewBadRequest
func NewBadRequest(err error, message ...string) *kerr.StatusError
NewBadRequest creates an error that indicates that the request is invalid and can not be processed.
NewConflict
func NewConflict(err error, message ...string) *kerr.StatusError
NewConflict returns an error indicating the item can't be updated as provided.
NewForbidden
func NewForbidden(reason string) *kerr.StatusError
NewForbidden returns an error indicating the requested action was forbidden
NewInternalError
func NewInternalError(err error, message ...string) *kerr.StatusError
NewInternalError returns an error indicating the item is invalid and cannot be processed.
NewMethodNotSupported
func NewMethodNotSupported(err error, message ...string) *kerr.StatusError
NewMethodNotSupported returns an error indicating the requested action is not supported.
NewNotFound
func NewNotFound(err error, message ...string) *kerr.StatusError
NewNotFound returns a new error which indicates that the requested resource was not found.
NewResourceExpired
func NewResourceExpired(message string) *kerr.StatusError
NewResourceExpired creates an error that indicates that the requested resource content has expired
NewStatusError
func NewStatusError(status int, err error, message ...string) *kerr.StatusError
NewStatusError returns a generic status type error
NewUnauthorized
func NewUnauthorized(reason string) *kerr.StatusError
NewUnauthorized returns an error indicating the client is not authorized to perform the requested action.
Types
Forms
type Forms http.Request
Forms a new enhancement of http.Request
Forms.Bool
func (f *Forms) Bool(key string) (bool, error)
Bool returns request form as bool
Forms.Escape
func (f *Forms) Escape(key string) (string, error)
Escape returns request form as escaped string
Forms.Float32
func (f *Forms) Float32(key string) (float32, error)
Float32 returns request form as float32
Forms.Float64
func (f *Forms) Float64(key string) (float64, error)
Float64 returns request form as float64
Forms.Int
func (f *Forms) Int(key string) (int, error)
Int returns request form as int
Forms.Int32
func (f *Forms) Int32(key string) (int32, error)
Int32 returns request form as int32
Forms.Int64
func (f *Forms) Int64(key string) (int64, error)
Int64 returns request form as int64
Forms.MustBool
func (f *Forms) MustBool(key string, defaults ...bool) bool
MustBool returns request form as bool with default
Forms.MustEscape
func (f *Forms) MustEscape(key string, defaults ...string) string
MustEscape returns request form as escaped string with default
Forms.MustFloat32
func (f *Forms) MustFloat32(key string, defaults ...float32) float32
MustFloat32 returns request form as float32 with default
Forms.MustFloat64
func (f *Forms) MustFloat64(key string, defaults ...float64) float64
MustFloat64 returns request form as float64 with default
Forms.MustInt
func (f *Forms) MustInt(key string, defaults ...int) int
MustInt returns request form as int with default
Forms.MustInt32
func (f *Forms) MustInt32(key string, defaults ...int32) int32
MustInt32 returns request form as int32 with default
Forms.MustInt64
func (f *Forms) MustInt64(key string, defaults ...int64) int64
MustInt64 returns request form as int64 with default
Forms.MustString
func (f *Forms) MustString(key string, defaults ...string) string
MustString returns request form as string with default
Forms.MustStrings
func (f *Forms) MustStrings(key string, defaults ...[]string) []string
MustStrings returns request form as strings with default
Forms.MustTrimmed
func (f *Forms) MustTrimmed(key string, defaults ...string) string
MustTrimmed returns request form as string with default
Forms.MustUint
func (f *Forms) MustUint(key string, defaults ...uint) uint
MustUint returns request form as uint with default
Forms.MustUint32
func (f *Forms) MustUint32(key string, defaults ...uint32) uint32
MustUint32 returns request form as uint32 with default
Forms.MustUint64
func (f *Forms) MustUint64(key string, defaults ...uint64) uint64
MustUint64 returns request form as uint64 with default
Forms.String
func (f *Forms) String(key string) (string, error)
String returns request form as string
Forms.Strings
func (f *Forms) Strings(key string) ([]string, error)
Strings returns request form as strings
Forms.Trimmed
func (f *Forms) Trimmed(key string) (string, error)
Trimmed returns request form as string with trimed spaces left and right
Forms.Uint
func (f *Forms) Uint(key string) (uint, error)
Uint returns request form as uint
Forms.Uint32
func (f *Forms) Uint32(key string) (uint32, error)
Uint32 returns request form as uint32
Forms.Uint64
func (f *Forms) Uint64(key string) (uint64, error)
Uint64 returns request form as uint64
Forms.Values
func (f *Forms) Values() url.Values
Values returns http.Request values
Request
type Request interface {
Request() *http.Request
// url path parameters
Params(p string) string
ParamsInt(p string) int
ParamsInt64(p string) int64
ParamsFloat64(name string) float64
SetParams(k, v string)
// query parameters
Query(key string, defaults ...string) string
QueryTrim(key string, defaults ...string) string
QueryStrings(key string, defaults ...[]string) []string
QueryInt(key string, defaults ...int) int
QueryInt64(key string, defaults ...int64) int64
QueryBool(key string, defaults ...bool) bool
}
ResponseWriter
type ResponseWriter interface {
http.ResponseWriter
R() Request
// render functions
TemplateLookup(t string) *template.Template
Render(e render.Engine, data interface{})
Data(status int, v []byte)
HTML(status int, name string, binding interface{}, htmlOpt ...render.HTMLOptions)
JSON(status int, v interface{})
JSONP(status int, callback string, v interface{})
Text(status int, v string)
XML(status int, v interface{})
Error(status int, contents ...interface{})
// extended ResponseWriter methods
Written() bool
// Status returns the HTTP status of the request, or 0 if one has not
// yet been sent.
Status() int
// BytesWritten returns the total number of bytes sent to the client.
BytesWritten() int
// API error
APIError(err error) int
// misc render/response functions
Redirect(location string, status ...int)
RedirectToFirst(appURL, appSubURL string, location ...string)
HTMLString(name string, binding interface{}, htmlOpt ...render.HTMLOptions) (string, error)
ServeContent(name string, r io.ReadSeeker, params ...interface{})
ServeFile(file string, names ...string)
}
NewResponseWriter
func NewResponseWriter(w http.ResponseWriter, req *http.Request, r *render.Render, sink logr.LogSink) ResponseWriter