Documentation ¶
Index ¶
- Constants
- Variables
- func D(f string, args ...any)
- func DBType() string
- func Dump(v ...interface{})
- func Erro(f string, args ...interface{})
- func Exists(path string) bool
- func Find(out interface{}, args ...interface{}) error
- func FixedPort(port string) string
- func Info(f string, args ...interface{})
- func IsChild() bool
- func LocalIP() (ip net.IP, err error)
- func Log(f string, args ...interface{})
- func MIME(extension string) (mime string)
- func MakePath(name, dst string, args ...interface{}) (string, string, error)
- func NewTree() *tree
- func Panicf(s string, args ...interface{})
- func ReadFile(path string, fs http.FileSystem) ([]byte, error)
- func RegHandle(mods ...any)
- func RegisterModule(inst Module)
- func SaveConfigFile(conf map[string]interface{}) error
- func StatusMessage(status int) string
- func ToHandle(src string) string
- func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error
- func Warn(f string, args ...interface{})
- type Array
- type Core
- func (c *Core) ALL(path string, handler ...interface{}) error
- func (c *Core) AddHandle(methods interface{}, path string, handler interface{}, static ...bool) error
- func (c *Core) Connect(path string, handler ...interface{}) error
- func (c *Core) Delete(path string, handler ...interface{}) error
- func (c *Core) Get(path string, handler ...interface{}) error
- func (c *Core) GoListenAndServe(addr ...string) error
- func (c *Core) GoListenAndServeContext(ctx context.Context, addr ...string) error
- func (c *Core) GoServe(ctx context.Context, ln net.Listener) error
- func (c *Core) Head(path string, handler ...interface{}) error
- func (c *Core) ListenAndServe(addr ...string) error
- func (c *Core) NotFound(ctx *Ctx, err error)
- func (c *Core) Options(path string, handler ...interface{}) error
- func (c *Core) Patch(path string, handler ...interface{}) error
- func (c *Core) Post(path string, handler ...interface{}) error
- func (c *Core) Put(path string, handler ...interface{}) error
- func (c *Core) Serve(ln net.Listener) error
- func (c *Core) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (c *Core) SetFuncMap(funcMap template.FuncMap) *Core
- func (c *Core) Shutdown() error
- func (c *Core) Static(relativePath, dirname string) *Core
- func (c *Core) StaticFS(relativePath string, ef *embed.FS) *Core
- func (c *Core) Trace(path string, handler ...interface{}) error
- func (c *Core) Use(args ...interface{}) *Core
- func (c *Core) Wait() error
- type Ctx
- func (c *Ctx) Abort(args ...interface{}) *Ctx
- func (c *Ctx) AbortJSON(data interface{}) error
- func (c *Ctx) AbortToJSON(data interface{}, err error) error
- func (c *Ctx) Cookie(cookie *http.Cookie)
- func (c *Ctx) Cookies(name string) (string, error)
- func (c *Ctx) Core() *Core
- func (c *Ctx) File(filepath string)
- func (c *Ctx) FileAttachment(filepath, filename string)
- func (c *Ctx) FileFromFS(filepath string, fs http.FileSystem)
- func (c *Ctx) Flush(data interface{}, statusCode ...int) error
- func (c *Ctx) FormFile(key string) (*multipart.FileHeader, error)
- func (c *Ctx) FormValue(key string, def ...string) string
- func (c *Ctx) FromValues(key string, def ...[]string) []string
- func (c *Ctx) Get(key string) (val interface{}, ok bool)
- func (c *Ctx) GetAs(key string, v interface{}) error
- func (c *Ctx) GetBool(key string) (value bool)
- func (c *Ctx) GetDuration(key string) (d time.Duration)
- func (c *Ctx) GetFloat64(key string, def ...float64) (value float64)
- func (c *Ctx) GetHeader(key string) string
- func (c *Ctx) GetInt(key string, def ...int) (i int)
- func (c *Ctx) GetInt64(key string, def ...int64) (i int64)
- func (c *Ctx) GetMap(key string, def ...map[string]interface{}) (value map[string]interface{})
- func (c *Ctx) GetMapString(key string, def ...map[string]string) (value map[string]string)
- func (c *Ctx) GetMapStringSlice(key string, def ...map[string][]string) (value map[string][]string)
- func (c *Ctx) GetParam(k string, def ...string) string
- func (c *Ctx) GetParamInt(k string, def ...int) int
- func (c *Ctx) GetParamUid(k string, def ...uid.UID) uid.UID
- func (c *Ctx) GetStatus() int
- func (c *Ctx) GetString(key string, def ...string) (value string)
- func (c *Ctx) GetStrings(key string, def ...[]string) (value []string)
- func (c *Ctx) GetTime(key string) (t time.Time)
- func (c *Ctx) GetUint(key string, def ...uint) (i uint)
- func (c *Ctx) GetUint64(key string, def ...uint64) (i uint64)
- func (c *Ctx) JSON(data interface{}) error
- func (c *Ctx) JSONP(data interface{}, callback ...string) error
- func (c *Ctx) Method() string
- func (c *Ctx) Next()
- func (c *Ctx) Params() params
- func (c *Ctx) Path() string
- func (c *Ctx) ReadBody(out interface{}) error
- func (c *Ctx) Redirect(to string, stCode ...int)
- func (c *Ctx) RedirectJS(to string, msg ...string)
- func (c *Ctx) RemoteIP() net.IP
- func (c *Ctx) RemoveCookie(name, path string, dom ...string)
- func (c *Ctx) Render(f string, bind ...interface{}) error
- func (c *Ctx) SaveFile(key, dst string, args ...interface{}) (relpath, abspath string, err error)
- func (c *Ctx) SaveFiles(key, dst string, args ...any) (rel Array, err error)
- func (c *Ctx) Send(buf []byte) error
- func (c *Ctx) SendStatus(status int, msg ...string) error
- func (c *Ctx) SendString(str ...interface{}) error
- func (c *Ctx) Set(key string, val interface{})
- func (c *Ctx) SetCookie(name, value string, exp time.Time, path string, args ...interface{})
- func (c *Ctx) SetHeader(key, value string)
- func (c *Ctx) SetParam(k, v string)
- func (c *Ctx) Status(status int) *Ctx
- func (c *Ctx) Stream(step func(w io.Writer) bool) bool
- func (c *Ctx) ToJSON(data interface{}, err error) error
- func (c *Ctx) Vars() map[string]any
- func (c *Ctx) ViewReload()
- func (c *Ctx) ViewTheme(theme string)
- type DB
- type Engine
- type ErrType
- type Error
- type Handler
- type HandlerFunc
- type HandlerFuncs
- type InmemoryListener
- type InvalidUnmarshalError
- type LoggerConfig
- type Map
- type Mod
- type Model
- type Models
- type Module
- type ModuleInfo
- type NextPages
- type NotFoundFunc
- type Options
- func (c *Options) GetAs(k string, v interface{}) error
- func (c *Options) GetBool(k string, def ...bool) bool
- func (c *Options) GetInt(k string, def ...int) int
- func (c *Options) GetInt64(k string, def ...int64) int64
- func (c *Options) GetMap(k string, def ...Options) Options
- func (c *Options) GetString(k string, def ...string) string
- func (c *Options) GetStrings(k string, def ...[]string) []string
- func (c *Options) ToString(k string, def ...string) string
- func (c *Options) Value(k string) (interface{}, bool)
- type Pages
- type PipeConns
- type RecoveryFunc
- type ResponseWriter
- type StringOrNil
- type TextEngine
- func (ve *TextEngine) AddFunc(name string, fn interface{}) Views
- func (ve *TextEngine) DoTheme(theme string)
- func (ve *TextEngine) Execute(out io.Writer, tpl string, binding interface{}, layout ...string) error
- func (ve *TextEngine) Layout(layout string) *TextEngine
- func (ve *TextEngine) Load() error
- func (ve *TextEngine) SetReload()
- func (ve *TextEngine) Theme(theme string)
- type UUID
- type ViewEngine
- func (ve *ViewEngine) AddFunc(name string, fn interface{}) Views
- func (ve *ViewEngine) DoTheme(theme string)
- func (ve *ViewEngine) Execute(out io.Writer, tpl string, binding interface{}, layout ...string) error
- func (ve *ViewEngine) Layout(layout string) *ViewEngine
- func (ve *ViewEngine) Load() error
- func (ve *ViewEngine) SetReload()
- func (ve *ViewEngine) Theme(theme string)
- type Views
- type Writers
Constants ¶
const ( StatusContinue = 100 // RFC 7231, 6.2.1 StatusSwitchingProtocols = 101 // RFC 7231, 6.2.2 StatusProcessing = 102 // RFC 2518, 10.1 StatusEarlyHints = 103 // RFC 8297 StatusOK = 200 // RFC 7231, 6.3.1 StatusCreated = 201 // RFC 7231, 6.3.2 StatusAccepted = 202 // RFC 7231, 6.3.3 StatusNonAuthoritativeInformation = 203 // RFC 7231, 6.3.4 StatusNoContent = 204 // RFC 7231, 6.3.5 StatusResetContent = 205 // RFC 7231, 6.3.6 StatusPartialContent = 206 // RFC 7233, 4.1 StatusMultiStatus = 207 // RFC 4918, 11.1 StatusAlreadyReported = 208 // RFC 5842, 7.1 StatusIMUsed = 226 // RFC 3229, 10.4.1 StatusMultipleChoices = 300 // RFC 7231, 6.4.1 StatusMovedPermanently = 301 // RFC 7231, 6.4.2 StatusFound = 302 // RFC 7231, 6.4.3 StatusSeeOther = 303 // RFC 7231, 6.4.4 StatusNotModified = 304 // RFC 7232, 4.1 StatusUseProxy = 305 // RFC 7231, 6.4.5 StatusTemporaryRedirect = 307 // RFC 7231, 6.4.7 StatusPermanentRedirect = 308 // RFC 7538, 3 StatusBadRequest = 400 // RFC 7231, 6.5.1 StatusPaymentRequired = 402 // RFC 7231, 6.5.2 StatusForbidden = 403 // RFC 7231, 6.5.3 StatusNotFound = 404 // RFC 7231, 6.5.4 StatusMethodNotAllowed = 405 // RFC 7231, 6.5.5 StatusNotAcceptable = 406 // RFC 7231, 6.5.6 StatusProxyAuthRequired = 407 // RFC 7235, 3.2 StatusRequestTimeout = 408 // RFC 7231, 6.5.7 StatusConflict = 409 // RFC 7231, 6.5.8 StatusGone = 410 // RFC 7231, 6.5.9 StatusLengthRequired = 411 // RFC 7231, 6.5.10 StatusPreconditionFailed = 412 // RFC 7232, 4.2 StatusRequestEntityTooLarge = 413 // RFC 7231, 6.5.11 StatusRequestURITooLong = 414 // RFC 7231, 6.5.12 StatusUnsupportedMediaType = 415 // RFC 7231, 6.5.13 StatusRequestedRangeNotSatisfiable = 416 // RFC 7233, 4.4 StatusExpectationFailed = 417 // RFC 7231, 6.5.14 StatusTeapot = 418 // RFC 7168, 2.3.3 StatusMisdirectedRequest = 421 // RFC 7540, 9.1.2 StatusUnprocessableEntity = 422 // RFC 4918, 11.2 StatusLocked = 423 // RFC 4918, 11.3 StatusFailedDependency = 424 // RFC 4918, 11.4 StatusTooEarly = 425 // RFC 8470, 5.2. StatusUpgradeRequired = 426 // RFC 7231, 6.5.15 StatusPreconditionRequired = 428 // RFC 6585, 3 StatusTooManyRequests = 429 // RFC 6585, 4 StatusRequestHeaderFieldsTooLarge = 431 // RFC 6585, 5 StatusInternalServerError = 500 // RFC 7231, 6.6.1 StatusNotImplemented = 501 // RFC 7231, 6.6.2 StatusBadGateway = 502 // RFC 7231, 6.6.3 StatusGatewayTimeout = 504 // RFC 7231, 6.6.5 StatusHTTPVersionNotSupported = 505 // RFC 7231, 6.6.6 StatusVariantAlsoNegotiates = 506 // RFC 2295, 8.1 StatusInsufficientStorage = 507 // RFC 4918, 11.5 StatusLoopDetected = 508 // RFC 5842, 7.2 StatusNotExtended = 510 // RFC 2774, 7 StatusNetworkAuthenticationRequired = 511 // RFC 6585, 6 )
HTTP status codes were copied from net/http.
const ( HeaderAuthorization = "Authorization" HeaderProxyAuthenticate = "Proxy-Authenticate" HeaderProxyAuthorization = "Proxy-Authorization" HeaderWWWAuthenticate = "WWW-Authenticate" HeaderAge = "Age" HeaderCacheControl = "Cache-Control" HeaderClearSiteData = "Clear-Site-Data" HeaderExpires = "Expires" HeaderPragma = "Pragma" HeaderWarning = "Warning" HeaderAcceptCH = "Accept-CH" HeaderAcceptCHLifetime = "Accept-CH-Lifetime" HeaderContentDPR = "Content-DPR" HeaderDPR = "DPR" HeaderEarlyData = "Early-Data" HeaderSaveData = "Save-Data" HeaderViewportWidth = "Viewport-Width" HeaderWidth = "Width" HeaderETag = "ETag" HeaderIfMatch = "If-Match" HeaderIfModifiedSince = "If-Modified-Since" HeaderIfNoneMatch = "If-None-Match" HeaderIfUnmodifiedSince = "If-Unmodified-Since" HeaderLastModified = "Last-Modified" HeaderVary = "Vary" HeaderConnection = "Connection" HeaderKeepAlive = "Keep-Alive" HeaderAccept = "Accept" HeaderAcceptCharset = "Accept-Charset" HeaderAcceptEncoding = "Accept-Encoding" HeaderAcceptLanguage = "Accept-Language" HeaderCookie = "Cookie" HeaderExpect = "Expect" HeaderMaxForwards = "Max-Forwards" HeaderSetCookie = "Set-Cookie" HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials" HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers" HeaderAccessControlAllowMethods = "Access-Control-Allow-Methods" HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin" HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers" HeaderAccessControlMaxAge = "Access-Control-Max-Age" HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers" HeaderAccessControlRequestMethod = "Access-Control-Request-Method" HeaderOrigin = "Origin" HeaderTimingAllowOrigin = "Timing-Allow-Origin" HeaderXPermittedCrossDomainPolicies = "X-Permitted-Cross-Domain-Policies" HeaderDNT = "DNT" HeaderTk = "Tk" HeaderContentDisposition = "Content-Disposition" HeaderContentEncoding = "Content-Encoding" HeaderContentLanguage = "Content-Language" HeaderContentLength = "Content-Length" HeaderContentLocation = "Content-Location" HeaderContentType = "Content-Type" HeaderForwarded = "Forwarded" HeaderVia = "Via" HeaderXForwardedFor = "X-Forwarded-For" HeaderXForwardedHost = "X-Forwarded-Host" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXForwardedProtocol = "X-Forwarded-Protocol" HeaderXForwardedSsl = "X-Forwarded-Ssl" HeaderXUrlScheme = "X-Url-Scheme" HeaderLocation = "Location" HeaderFrom = "From" HeaderHost = "Host" HeaderReferer = "Referer" HeaderReferrerPolicy = "Referrer-Policy" HeaderUserAgent = "User-Agent" HeaderAllow = "Allow" HeaderServer = "Server" HeaderAcceptRanges = "Accept-Ranges" HeaderContentRange = "Content-Range" HeaderIfRange = "If-Range" HeaderRange = "Range" HeaderContentSecurityPolicy = "Content-Security-Policy" HeaderContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only" HeaderCrossOriginResourcePolicy = "Cross-Origin-Resource-Policy" HeaderExpectCT = "Expect-CT" HeaderFeaturePolicy = "Feature-Policy" HeaderPublicKeyPins = "Public-Key-Pins" HeaderPublicKeyPinsReportOnly = "Public-Key-Pins-Report-Only" HeaderStrictTransportSecurity = "Strict-Transport-Security" HeaderUpgradeInsecureRequests = "Upgrade-Insecure-Requests" HeaderXContentTypeOptions = "X-Content-Type-Options" HeaderXDownloadOptions = "X-Download-Options" HeaderXFrameOptions = "X-Frame-Options" HeaderXPoweredBy = "X-Powered-By" HeaderXXSSProtection = "X-XSS-Protection" HeaderLastEventID = "Last-Event-ID" HeaderNEL = "NEL" HeaderPingFrom = "Ping-From" HeaderPingTo = "Ping-To" HeaderReportTo = "Report-To" HeaderTE = "TE" HeaderTrailer = "Trailer" HeaderTransferEncoding = "Transfer-Encoding" HeaderSecWebSocketAccept = "Sec-WebSocket-Accept" HeaderSecWebSocketExtensions = "Sec-WebSocket-Extensions" HeaderSecWebSocketKey = "Sec-WebSocket-Key" HeaderSecWebSocketProtocol = "Sec-WebSocket-Protocol" HeaderSecWebSocketVersion = "Sec-WebSocket-Version" HeaderAcceptPatch = "Accept-Patch" HeaderAcceptPushPolicy = "Accept-Push-Policy" HeaderAcceptSignature = "Accept-Signature" HeaderAltSvc = "Alt-Svc" HeaderDate = "Date" HeaderIndex = "Index" HeaderLargeAllocation = "Large-Allocation" HeaderLink = "Link" HeaderPushPolicy = "Push-Policy" HeaderRetryAfter = "Retry-After" HeaderServerTiming = "Server-Timing" HeaderSignature = "Signature" HeaderSignedHeaders = "Signed-Headers" HeaderSourceMap = "SourceMap" HeaderUpgrade = "Upgrade" HeaderXDNSPrefetchControl = "X-DNS-Prefetch-Control" HeaderXPingback = "X-Pingback" HeaderXRequestID = "X-Request-ID" HeaderXRequestedWith = "X-Requested-With" HeaderXRobotsTag = "X-Robots-Tag" HeaderXUACompatible = "X-UA-Compatible" )
HTTP Headers were copied from net/http.
const ( MIMETextXML = "text/xml" MIMETextHTML = "text/html" MIMETextPlain = "text/plain" MIMEApplicationXML = "application/xml" MIMEApplicationJSON = "application/json" MIMEApplicationJavaScript = "application/javascript" MIMEApplicationForm = "application/x-www-form-urlencoded" MIMEOctetStream = "application/octet-stream" MIMEMultipartForm = "multipart/form-data" MIMETextXMLCharsetUTF8 = "text/xml; charset=utf-8" MIMETextHTMLCharsetUTF8 = "text/html; charset=utf-8" MIMETextPlainCharsetUTF8 = "text/plain; charset=utf-8" MIMEApplicationXMLCharsetUTF8 = "application/xml; charset=utf-8" MIMEApplicationJSONCharsetUTF8 = "application/json; charset=utf-8" MIMEApplicationJavaScriptCharsetUTF8 = "application/javascript; charset=utf-8" )
MIME types that are commonly used
const ( MethodUse = "USE" MethodConnect = "CONNECT" // RFC 7231, 4.3.6 MethodDelete = "DELETE" // RFC 7231, 4.3.5 MethodGet = "GET" // RFC 7231, 4.3.1 MethodHead = "HEAD" // RFC 7231, 4.3.2 MethodOptions = "OPTIONS" // RFC 7231, 4.3.7 MethodPatch = "PATCH" // RFC 5789 MethodPost = "POST" // RFC 7231, 4.3.3 MethodPut = "PUT" // RFC 7231, 4.3.4 MethodTrace = "TRACE" // RFC 7231, 4.3.8 )
HTTP methods were copied from net/http.
const ( DefaultDateFormat = "2006-01-02" DefaultDateTimeFormat = "2006-01-02 15:04" )
Revel's default date and time constants
Variables ¶
var ( ErrBadRequest = NewError(StatusBadRequest) // RFC 7231, 6.5.1 ErrPaymentRequired = NewError(StatusPaymentRequired) // RFC 7231, 6.5.2 ErrForbidden = NewError(StatusForbidden) // RFC 7231, 6.5.3 ErrNotFound = NewError(StatusNotFound) // RFC 7231, 6.5.4 ErrMethodNotAllowed = NewError(StatusMethodNotAllowed) // RFC 7231, 6.5.5 ErrNotAcceptable = NewError(StatusNotAcceptable) // RFC 7231, 6.5.6 ErrProxyAuthRequired = NewError(StatusProxyAuthRequired) // RFC 7235, 3.2 ErrRequestTimeout = NewError(StatusRequestTimeout) // RFC 7231, 6.5.7 ErrConflict = NewError(StatusConflict) // RFC 7231, 6.5.8 ErrGone = NewError(StatusGone) // RFC 7231, 6.5.9 ErrLengthRequired = NewError(StatusLengthRequired) // RFC 7231, 6.5.10 ErrPreconditionFailed = NewError(StatusPreconditionFailed) // RFC 7232, 4.2 ErrRequestEntityTooLarge = NewError(StatusRequestEntityTooLarge) // RFC 7231, 6.5.11 ErrRequestURITooLong = NewError(StatusRequestURITooLong) // RFC 7231, 6.5.12 ErrUnsupportedMediaType = NewError(StatusUnsupportedMediaType) // RFC 7231, 6.5.13 ErrRequestedRangeNotSatisfiable = NewError(StatusRequestedRangeNotSatisfiable) // RFC 7233, 4.4 ErrExpectationFailed = NewError(StatusExpectationFailed) // RFC 7231, 6.5.14 ErrTeapot = NewError(StatusTeapot) // RFC 7168, 2.3.3 ErrMisdirectedRequest = NewError(StatusMisdirectedRequest) // RFC 7540, 9.1.2 ErrUnprocessableEntity = NewError(StatusUnprocessableEntity) // RFC 4918, 11.2 ErrLocked = NewError(StatusLocked) // RFC 4918, 11.3 ErrFailedDependency = NewError(StatusFailedDependency) // RFC 4918, 11.4 ErrTooEarly = NewError(StatusTooEarly) // RFC 8470, 5.2. ErrUpgradeRequired = NewError(StatusUpgradeRequired) // RFC 7231, 6.5.15 ErrPreconditionRequired = NewError(StatusPreconditionRequired) // RFC 6585, 3 ErrTooManyRequests = NewError(StatusTooManyRequests) // RFC 6585, 4 ErrRequestHeaderFieldsTooLarge = NewError(StatusRequestHeaderFieldsTooLarge) // RFC 6585, 5 ErrInternalServerError = NewError(StatusInternalServerError) // RFC 7231, 6.6.1 ErrNotImplemented = NewError(StatusNotImplemented) // RFC 7231, 6.6.2 ErrBadGateway = NewError(StatusBadGateway) // RFC 7231, 6.6.3 ErrGatewayTimeout = NewError(StatusGatewayTimeout) // RFC 7231, 6.6.5 ErrHTTPVersionNotSupported = NewError(StatusHTTPVersionNotSupported) // RFC 7231, 6.6.6 ErrVariantAlsoNegotiates = NewError(StatusVariantAlsoNegotiates) // RFC 2295, 8.1 ErrInsufficientStorage = NewError(StatusInsufficientStorage) // RFC 4918, 11.5 ErrLoopDetected = NewError(StatusLoopDetected) // RFC 5842, 7.2 ErrNotExtended = NewError(StatusNotExtended) // RFC 2774, 7 ErrNetworkAuthenticationRequired = NewError(StatusNetworkAuthenticationRequired) // RFC 6585, 6 )
Errors
var ( // Error for handle not support. ErrHandlerNotFound = errors.New("handler not found") ErrHandleNotSupport = errors.New("handle does not support. Must use core.Handle, http.HandlerFunc or http.Handler") ErrDataTypeNotSupport = errors.New("dataType does not support") ErrNoConfig = errors.New("field global configuration not found") ErrContextMustBeSet = errors.New("context must be set") ErrNotStartedYet = errors.New("not started yet") // ErrInmemoryListenerClosed indicates that the InmemoryListener is already closed. ErrInmemoryListenerClosed = errors.New("InmemoryListener is already closed: use of closed network connection") )
var DefaultErrorWriter io.Writer = os.Stderr
DefaultErrorWriter is the default io.Writer used by Gin to debug errors
var (
DefaultOutput = io.Discard
)
var (
// ErrTimeout is returned from Read() or Write() on timeout.
ErrTimeout = &timeoutError{}
)
var Methods = []string{ MethodUse, MethodGet, MethodHead, MethodPost, MethodPut, MethodDelete, MethodConnect, MethodOptions, MethodTrace, MethodPatch, }
Methods methods slice
var UuidNil = UUID{uuid.Nil}
Functions ¶
func Find ¶ added in v0.0.3
func Find(out interface{}, args ...interface{}) error
Find find all data record max 10000
func IsChild ¶ added in v1.9.32
func IsChild() bool
IsChild determines if the current process is a child of Prefork
func MakePath ¶
MakePath make dir
path = {root}/{dst}/{id} @param name string filename dst string dst path root string root path optional id path optional type uid.UID, int, uint, int64,uint64 rename bool optional return relPath, absPath ` MakePath("favicon.png", "/images") (string) relpath "/images/10/favicon.png" (string) abspath "/images/10/favicon.png" MakePath("favicon.png", "/images", "/static") (string) relpath "/images/10/5hsbkthaadld/favicon.png" (string) abspath "/static/images/10/5hsbkthaadld/favicon.png" MakePath("favicon.png", "/images", "/static", uid.New()) (string) relpath "/images/10/5hsbkthaadld/5hsbkthaadld.png" (string) abspath "/static/images/10/5hsbkthaadld/5hsbkthaadld.png" 👇filename 👇dst 👇root 👇id 👇rename MakePath("favicon.png", "/images", "/static", uid.New(), true) (string) relpath "/images/10/5hsbkthaadld/5hsbkthaadld.png" (string) abspath "/static/images/10/5hsbkthaadld/5hsbkthaadld.png" `
func ReadFile ¶ added in v1.9.4
func ReadFile(path string, fs http.FileSystem) ([]byte, error)
ReadFile returns the raw content of a file
func RegisterModule ¶ added in v1.9.0
func RegisterModule(inst Module)
func SaveConfigFile ¶
func StatusMessage ¶
StatusMessage returns the correct message for the provided HTTP statuscode
Types ¶
type Array ¶ added in v0.0.2
type Array []interface{}
Array 数组类型
func (Array) FindHandle ¶ added in v0.0.5
func (Array) GormDataType ¶ added in v0.0.2
GormDataType schema.Field DataType
func (Array) StringsJoin ¶ added in v0.0.2
StringsJoin 链接为字符串
type Core ¶
type Core struct { *http.Server Debug bool Conf Options Views Views // Value of 'maxMemory' param that is given to http.Request's ParseMultipartForm // method call. MaxMultipartMemory int64 ViewFuncMap template.FuncMap RemoteIPHeaders []string Ln net.Listener NotFoundFunc NotFoundFunc // contains filtered or unexported fields }
func (*Core) AddHandle ¶
func (c *Core) AddHandle(methods interface{}, path string, handler interface{}, static ...bool) error
AddHandle
methods string || []string path string /foo handler core.Handle || http.HandlerFunc || http.Handler app.AddHandle("GET", "/foo", func(c*core.Ctx){ c.SendString("hello world") })
func (*Core) Get ¶
Get add get method
path string /foo handler core.Handle || http.HandlerFunc || http.Handler > add method c.Get("/foo", func(c *core.Ctx){ c.SendString("Hello world") })
func (*Core) GoListenAndServe ¶ added in v1.9.2
func (*Core) GoListenAndServeContext ¶ added in v1.9.2
func (*Core) ListenAndServe ¶
func (*Core) SetFuncMap ¶
SetFuncMap sets the FuncMap used for template.FuncMap.
type Ctx ¶
type Ctx struct { context.Context W ResponseWriter Resp http.ResponseWriter R *http.Request Config *Options // contains filtered or unexported fields }
func (*Ctx) AbortToJSON ¶ added in v0.0.2
func (*Ctx) Cookies ¶ added in v0.0.3
Cookie returns the named cookie provided in the request or ErrNoCookie if not found. And return the named cookie is unescaped. If multiple cookies match the given name, only one cookie will be returned.
func (*Ctx) FileAttachment ¶
FileAttachment writes the specified file into the body stream in an efficient way On the client side, the file will typically be downloaded with the given filename
func (*Ctx) FileFromFS ¶
func (c *Ctx) FileFromFS(filepath string, fs http.FileSystem)
FileFromFS writes the specified file from http.FileSystem into the body stream in an efficient way.
func (*Ctx) FormFile ¶
func (c *Ctx) FormFile(key string) (*multipart.FileHeader, error)
FormFile returns the first file for the provided form key. FormFile calls ParseMultipartForm and ParseForm if necessary.
func (*Ctx) FormValue ¶
FormValue Get query
key string def string default val optional
> GET /?name=Jack&id=
` name := c.FromValue("name") // name = Jack id := c.FromValue("id", "1") // id = 1 Because the default value is used `
func (*Ctx) FromValues ¶
FromValues returns a slice of strings for a given query key.
func (*Ctx) Get ¶
Get returns the value for the given key, ie: (value, true). If the value does not exists it returns (nil, false)
func (*Ctx) GetAs ¶
GetAs retrieve struct like c.Get("user").(User)
> Experimental function, problem unknown
func (*Ctx) GetDuration ¶
GetDuration returns the value associated with the key as a duration.
func (*Ctx) GetFloat64 ¶
GetFloat64 returns the value associated with the key as a float64.
func (*Ctx) GetMap ¶
GetMap returns the value associated with the key as a map of interfaces.
> return map[string]interface{}
func (*Ctx) GetMapString ¶
GetMapString returns the value associated with the key as a map of strings.
> return map[string]string
func (*Ctx) GetMapStringSlice ¶
GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings.
> return map[string][]string
func (*Ctx) GetParamInt ¶ added in v1.9.31
GetParamInt get int param, return -1 if failed
func (*Ctx) GetParamUid ¶ added in v1.9.31
GetParamInt get int param, return uid.Nil if failed
func (*Ctx) GetStrings ¶
GetStrings String Slice returns the value associated with the key as a slice of strings.
func (*Ctx) ReadBody ¶
ReadBody binds the request body to a struct. It supports decoding the following content types based on the Content-Type header: application/json, application/xml, application/x-www-form-urlencoded, multipart/form-data If none of the content types above are matched, it will return a ErrUnprocessableEntity error
out interface{} MIMEApplicationForm MIMEMultipartForm MIMETextXML must struct
func (*Ctx) RedirectJS ¶ added in v1.9.7
func (*Ctx) RemoteIP ¶
RemoteIP parses the IP from Request.RemoteAddr, normalizes and returns the IP (without the port). It also checks if the remoteIP is a trusted proxy or not. In order to perform this validation, it will see if the IP is contained within at least one of the CIDR blocks
func (*Ctx) RemoveCookie ¶ added in v0.0.3
func (*Ctx) SaveFile ¶
SaveFile upload file save to a folder
path = {root}/{dst}/{id} @param name string filename dst string dst path root string root path optional id path optional type uid.UID, int, uint, int64,uint64 rename bool optional return relPath, absPath c.SaveFile("file", "/images") (string) relpath "/images/10/favicon.png" (string) abspath "/images/10/favicon.png" c.SaveFile("file", "/images", "./static") (string) relpath "/images/10/5hsbkthaadld/favicon.png" (string) abspath "/static/images/10/5hsbkthaadld/favicon.png" c.SaveFile("file", "/images", "./static", uid.New()) (string) relpath "/images/10/5hsbkthaadld/5hsbkthaadld.png" (string) abspath "/static/images/10/5hsbkthaadld/5hsbkthaadld.png" 👇file 👇dst 👇root 👇id 👇rename c.SaveFile("file", "/images", "./static", uid.New(), true) (string) relpath "/images/10/5hsbkthaadld/5hsbkthaadld.png" (string) abspath "/static/images/10/5hsbkthaadld/5hsbkthaadld.png"
func (*Ctx) SendStatus ¶
SendStatus send status code
func (*Ctx) SendString ¶
SendString send string to client
func (*Ctx) SetCookie ¶
SetCookie adds a Set-Cookie header to the ResponseWriter's headers. The provided cookie must have a valid Name. Invalid cookies may be silently dropped.
func (*Ctx) Stream ¶
Stream sends a streaming response and returns a boolean indicates "Is client disconnected in middle of stream"
func (*Ctx) ViewReload ¶ added in v1.9.10
func (c *Ctx) ViewReload()
type Engine ¶ added in v1.9.0
type Engine struct { *Core Ctx context.Context EG *errgroup.Group // contains filtered or unexported fields }
func (*Engine) ListenAndServe ¶ added in v1.9.0
func (*Engine) ListenAndServeTLS ¶ added in v1.9.8
type ErrType ¶
type ErrType uint64
const ( // ErrTypeAny indicates any other error. ErrTypeAny ErrType = 1<<64 - 1 // ErrorTypeNu indicates any other error. ErrTypeNu = 2 )
type Error ¶
Error represents an error that occurred while handling a request.
type Handler ¶
type Handler struct { Handlers map[string]struct{} // Record callable handle ID string // contains filtered or unexported fields }
Handler base Handler
func (*Handler) Init ¶
func (h *Handler) Init()
Init do nothing wait children rewrite app start call this func
func (*Handler) Preload ¶
Preload do nothing wait children rewrite any request before call this func
func (*Handler) PushHandler ¶
PushHandler push list to PushHandler
type HandlerFunc ¶
type HandlerFunc func(*Ctx)
HandlerFunc defines the handlerFunc
func CustomRecoveryWithWriter ¶ added in v0.0.2
func CustomRecoveryWithWriter(out io.Writer, handle RecoveryFunc) HandlerFunc
CustomRecoveryWithWriter returns a middleware for a given writer that recovers from any panics and calls the provided handle func to handle it.
func Logger ¶ added in v0.0.2
func Logger(conf ...LoggerConfig) HandlerFunc
func Recovery ¶ added in v0.0.2
func Recovery() HandlerFunc
Recovery returns a middleware that recovers from any panics and writes a 500 if there was one.
func RecoveryWithWriter ¶ added in v0.0.2
func RecoveryWithWriter(out io.Writer, recovery ...RecoveryFunc) HandlerFunc
RecoveryWithWriter returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one.
type HandlerFuncs ¶
type HandlerFuncs []HandlerFunc
type InmemoryListener ¶
type InmemoryListener struct {
// contains filtered or unexported fields
}
InmemoryListener provides in-memory dialer<->net.Listener implementation.
It may be used either for fast in-process client<->server communications without network stack overhead or for client<->server tests.
func NewInmemoryListener ¶
func NewInmemoryListener() *InmemoryListener
NewInmemoryListener returns new in-memory dialer<->net.Listener.
func (*InmemoryListener) Accept ¶
func (ln *InmemoryListener) Accept() (net.Conn, error)
Accept implements net.Listener's Accept.
It is safe calling Accept from concurrently running goroutines.
Accept returns new connection per each Dial call.
func (*InmemoryListener) Addr ¶
func (ln *InmemoryListener) Addr() net.Addr
Addr implements net.Listener's Addr.
func (*InmemoryListener) Close ¶
func (ln *InmemoryListener) Close() error
Close implements net.Listener's Close.
type InvalidUnmarshalError ¶
An InvalidUnmarshalError describes an invalid argument passed to Unmarshal. (The argument to Unmarshal must be a non-nil pointer.)
func (*InvalidUnmarshalError) Error ¶
func (e *InvalidUnmarshalError) Error() string
type LoggerConfig ¶ added in v0.0.2
type Map ¶ added in v0.0.2
type Map map[string]interface{}
Map map[string]interface{}
func (Map) GormDataType ¶ added in v0.0.3
GormDataType schema.Field DataType
type Model ¶ added in v0.0.2
type Model struct { ID uid.UID `gorm:"primaryKey" json:"id,omitempty"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *gorm.DeletedAt `json:"deleted_at,omitempty"` }
func (*Model) BeforeCreate ¶ added in v0.0.2
type Models ¶ added in v1.9.33
type Models struct { ID UUID `gorm:"primaryKey" json:"id,omitempty"` CreatedAt time.Time `json:"created_at" gorm:"<-:create"` UpdatedAt time.Time `json:"updated_at"` DeletedAt *gorm.DeletedAt `json:"deleted_at,omitempty" gorm:"index"` }
func (*Models) BeforeCreate ¶ added in v1.9.33
type Module ¶ added in v1.9.0
type Module interface {
Module() ModuleInfo
}
type ModuleInfo ¶ added in v1.9.0
func GetModule ¶ added in v1.9.0
func GetModule(id string) (ModuleInfo, error)
func GetModules ¶ added in v1.9.0
func GetModules(scope string) []ModuleInfo
type NextPages ¶ added in v1.9.34
type Options ¶ added in v1.9.1
type Options map[string]interface{}
var (
Conf Options
)
func LoadConfigFile ¶
func (*Options) GetStrings ¶ added in v1.9.1
type Pages ¶ added in v0.0.2
type PipeConns ¶
type PipeConns struct {
// contains filtered or unexported fields
}
PipeConns provides bi-directional connection pipe, which use in-process memory as a transport.
PipeConns must be created by calling NewPipeConns.
PipeConns has the following additional features comparing to connections returned from net.Pipe():
- It is faster.
- It buffers Write calls, so there is no need to have concurrent goroutine calling Read in order to unblock each Write call.
- It supports read and write deadlines.
PipeConns is NOT safe for concurrent use by multiple goroutines!
func NewPipeConns ¶
func NewPipeConns() *PipeConns
NewPipeConns returns new bi-directional connection pipe.
PipeConns is NOT safe for concurrent use by multiple goroutines!
type RecoveryFunc ¶ added in v0.0.2
type RecoveryFunc func(c *Ctx, err interface{})
RecoveryFunc defines the function passable to CustomRecovery.
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter http.Hijacker http.Flusher // Returns the HTTP response status code of the current request. Status() int // Returns the number of bytes already written into the response http body. // See Written() Size() int // Writes the string into the response body. WriteString(string) (int, error) // Returns true if the response body was already written. Written() bool // Forces to write the http header (status code + headers). DoWriteHeader() // get the http.Pusher for server push Pusher() http.Pusher }
ResponseWriter ...
type StringOrNil ¶ added in v0.0.2
type StringOrNil string
空字符串 存入数据库 存 NULL ,这样会跳过数据库唯一索引的检查
func (*StringOrNil) Scan ¶ added in v0.0.2
func (s *StringOrNil) Scan(src interface{}) error
implements sql.Scanner, will be invoked automatically when read from the db
func (StringOrNil) String ¶ added in v0.0.2
func (s StringOrNil) String() string
type TextEngine ¶ added in v1.9.11
func (*TextEngine) AddFunc ¶ added in v1.9.11
func (ve *TextEngine) AddFunc(name string, fn interface{}) Views
func (*TextEngine) DoTheme ¶ added in v1.9.11
func (ve *TextEngine) DoTheme(theme string)
DoTheme 调用已装载的主题
func (*TextEngine) Layout ¶ added in v1.9.11
func (ve *TextEngine) Layout(layout string) *TextEngine
func (*TextEngine) SetReload ¶ added in v1.9.11
func (ve *TextEngine) SetReload()
SetReload 设置模版需要更新
func (*TextEngine) Theme ¶ added in v1.9.11
func (ve *TextEngine) Theme(theme string)
Theme sets theme
type UUID ¶ added in v1.9.33
func UUIDFromString ¶ added in v1.9.33
type ViewEngine ¶ added in v1.9.4
func NewView ¶ added in v1.9.4
func NewView(directory, ext string, args ...interface{}) *ViewEngine
func (*ViewEngine) AddFunc ¶ added in v1.9.4
func (ve *ViewEngine) AddFunc(name string, fn interface{}) Views
func (*ViewEngine) DoTheme ¶ added in v1.9.4
func (ve *ViewEngine) DoTheme(theme string)
DoTheme 调用已装载的主题
func (*ViewEngine) Layout ¶ added in v1.9.4
func (ve *ViewEngine) Layout(layout string) *ViewEngine
func (*ViewEngine) SetReload ¶ added in v1.9.10
func (ve *ViewEngine) SetReload()
SetReload 设置模版需要更新
func (*ViewEngine) Theme ¶ added in v1.9.4
func (ve *ViewEngine) Theme(theme string)
Theme sets theme
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
examples
|
|
Package reuseport provides TCP net.Listener with SO_REUSEPORT support.
|
Package reuseport provides TCP net.Listener with SO_REUSEPORT support. |
Package tcplisten provides customizable TCP net.Listener with various performance-related options:
|
Package tcplisten provides customizable TCP net.Listener with various performance-related options: |