core

package module
v1.9.36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2023 License: MIT Imports: 50 Imported by: 1

README

Web framework

  • golang workframe
  • support router
  • auto register router
  • micro serve
  • easy run
  • support go module go.mod

more doc

if error output cannot use column (variable of type Column) as gorm.ColumnType value in argument to append: unknown field WithReturning in struct literal of type callbacks.Config

go get gorm.io/gorm
go get gorm.io/driver/mysql
go get gorm.io/driver/sqlite
go get gorm.io/driver/postgres

https://godoc.org/github.com/xs23933/core

examples


package main

import (
	"github.com/xs23933/web"
)

// handler.go
type Handler struct {
    web.Handler
}

// Init Init
func (h *Handler) Init() {
	h.SetPrefix("/api") // Add prefix
}

// Get get method
// get /api/
func (Handler) Get(c *web.Ctx) {
    c.Send("Hello world")
}

// GetParams Get something params
//  get /api/:param?
func (Handler) GetParams(c *core.Ctx) {
    c.Send("Param: ", c.Params("param"))
}

// PostParam PostParam
func (Handler) PostParam(c *core.Ctx) {
    form := make(map[string]interface{}, 0)  // or some struct
    c.ReadBody(&form)
	c.Send("Param ", c.Params("param"))
}

// PutParams 可选参数
// put /:param?
func (Handler) PutParams(c *core.Ctx) {
    form := make(map[string]interface{}, 0)  // or some struct
    c.ReadBody(&form)
	c.Send("Param? ", c.Params("param"))
}

// main.go
func main(){
    app := core.NewEngine(&core.LoadConfigFile("./config.yml"))

    app.Use(new(Handler))
    // Serve(port) 
    if err := app.Serve(80); err != nil {
        panic(err)
    }
}


go run example/main.go

+ ---- Auto register router ---- +
| GET	/api/
| GET	/api/:param?
| POST	/api/:param
| PUT	/api/:param?
+ ------------------------------ +
Started server on 0.0.0.0:80

Documentation

Index

Constants

View Source
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
	StatusUnauthorized                  = 401 // RFC 7235, 3.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
	StatusUnavailableForLegalReasons    = 451 // RFC 7725, 3
	StatusInternalServerError           = 500 // RFC 7231, 6.6.1
	StatusNotImplemented                = 501 // RFC 7231, 6.6.2
	StatusBadGateway                    = 502 // RFC 7231, 6.6.3
	StatusServiceUnavailable            = 503 // RFC 7231, 6.6.4
	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.

View Source
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.

View Source
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

View Source
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.

View Source
const (
	DefaultDateFormat     = "2006-01-02"
	DefaultDateTimeFormat = "2006-01-02 15:04"
)

Revel's default date and time constants

Variables

View Source
var (
	ErrBadRequest                    = NewError(StatusBadRequest)                    // RFC 7231, 6.5.1
	ErrUnauthorized                  = NewError(StatusUnauthorized)                  // RFC 7235, 3.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
	ErrUnavailableForLegalReasons    = NewError(StatusUnavailableForLegalReasons)    // RFC 7725, 3
	ErrInternalServerError           = NewError(StatusInternalServerError)           // RFC 7231, 6.6.1
	ErrNotImplemented                = NewError(StatusNotImplemented)                // RFC 7231, 6.6.2
	ErrBadGateway                    = NewError(StatusBadGateway)                    // RFC 7231, 6.6.3
	ErrServiceUnavailable            = NewError(StatusServiceUnavailable)            // RFC 7231, 6.6.4
	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

View Source
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")
)
View Source
var DefaultErrorWriter io.Writer = os.Stderr

DefaultErrorWriter is the default io.Writer used by Gin to debug errors

View Source
var (
	DefaultOutput = io.Discard
)
View Source
var (
	// ErrTimeout is returned from Read() or Write() on timeout.
	ErrTimeout = &timeoutError{}
)

Methods methods slice

View Source
var UuidNil = UUID{uuid.Nil}

Functions

func D added in v0.0.2

func D(f string, args ...any)

func DBType added in v1.9.5

func DBType() string

func Dump

func Dump(v ...interface{})

Dump 打印数据信息

func Erro added in v0.0.2

func Erro(f string, args ...interface{})

error logger

func Exists

func Exists(path string) bool

Exists check file or path exists

func Find added in v0.0.3

func Find(out interface{}, args ...interface{}) error

Find find all data record max 10000

func FixedPort added in v1.9.2

func FixedPort(port string) string

func Info added in v1.9.29

func Info(f string, args ...interface{})

info logger

func IsChild added in v1.9.32

func IsChild() bool

IsChild determines if the current process is a child of Prefork

func LocalIP added in v1.9.2

func LocalIP() (ip net.IP, err error)

func Log added in v0.0.2

func Log(f string, args ...interface{})

func MIME

func MIME(extension string) (mime string)

GetMIME returns the content-type of a file extension

func MakePath

func MakePath(name, dst string, args ...interface{}) (string, string, error)

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 NewTree

func NewTree() *tree

func Panicf

func Panicf(s string, args ...interface{})

Panicf format panic

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 RegHandle added in v1.9.32

func RegHandle(mods ...any)

func RegisterModule added in v1.9.0

func RegisterModule(inst Module)

func SaveConfigFile

func SaveConfigFile(conf map[string]interface{}) error

func StatusMessage

func StatusMessage(status int) string

StatusMessage returns the correct message for the provided HTTP statuscode

func ToHandle added in v0.0.2

func ToHandle(src string) string

ToHandle 转换名称为handle

func Walk added in v1.9.4

func Walk(fs http.FileSystem, root string, walkFn filepath.WalkFunc) error

Walk walks the filesystem rooted at root, calling walkFn for each file or directory in the filesystem, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order.

func Warn added in v0.0.2

func Warn(f string, args ...interface{})

warning logger

Types

type Array added in v0.0.2

type Array []interface{}

Array 数组类型

func (Array) FindHandle added in v0.0.5

func (d Array) FindHandle(handle, value string) Map

func (Array) GormDataType added in v0.0.2

func (Array) GormDataType() string

GormDataType schema.Field DataType

func (*Array) Scan added in v0.0.2

func (d *Array) Scan(src interface{}) error

Scan 数据驱动接口

func (Array) String added in v0.0.2

func (d Array) String() []string

Strings 转换为 []string

func (Array) StringsJoin added in v0.0.2

func (d Array) StringsJoin(sp string) string

StringsJoin 链接为字符串

func (Array) Value added in v0.0.2

func (d Array) Value() (driver.Value, error)

Value 数据驱动接口

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 Default added in v0.0.2

func Default(conf ...Options) *Core

Default init and use Logger And Recovery

func New

func New(conf ...Options) *Core

New New Core

func (*Core) ALL added in v1.9.14

func (c *Core) ALL(path string, handler ...interface{}) error

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) Connect

func (c *Core) Connect(path string, handler ...interface{}) error

Connect add get method

> see Get

func (*Core) Delete

func (c *Core) Delete(path string, handler ...interface{}) error

Delete add get method

> see Get

func (*Core) Get

func (c *Core) Get(path string, handler ...interface{}) error

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 (c *Core) GoListenAndServe(addr ...string) error

func (*Core) GoListenAndServeContext added in v1.9.2

func (c *Core) GoListenAndServeContext(ctx context.Context, addr ...string) error

func (*Core) GoServe added in v1.9.2

func (c *Core) GoServe(ctx context.Context, ln net.Listener) error

func (*Core) Head

func (c *Core) Head(path string, handler ...interface{}) error

Head add get method

> see Get

func (*Core) ListenAndServe

func (c *Core) ListenAndServe(addr ...string) error

func (*Core) NotFound added in v1.9.14

func (c *Core) NotFound(ctx *Ctx, err error)

func (*Core) Options

func (c *Core) Options(path string, handler ...interface{}) error

Options add get method

> see Get

func (*Core) Patch

func (c *Core) Patch(path string, handler ...interface{}) error

Patch add get method

> see Get

func (*Core) Post

func (c *Core) Post(path string, handler ...interface{}) error

Post add get method

> see Get

func (*Core) Put

func (c *Core) Put(path string, handler ...interface{}) error

Put add get method

> see Get

func (*Core) Serve

func (c *Core) Serve(ln net.Listener) error

func (*Core) ServeHTTP

func (c *Core) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Core) SetFuncMap

func (c *Core) SetFuncMap(funcMap template.FuncMap) *Core

SetFuncMap sets the FuncMap used for template.FuncMap.

func (*Core) Shutdown added in v1.9.4

func (c *Core) Shutdown() error

func (*Core) Static

func (c *Core) Static(relativePath, dirname string) *Core

func (*Core) StaticFS added in v1.9.3

func (c *Core) StaticFS(relativePath string, ef *embed.FS) *Core

func (*Core) Trace

func (c *Core) Trace(path string, handler ...interface{}) error

Trace add get method

> see Get

func (*Core) Use

func (c *Core) Use(args ...interface{}) *Core

func (*Core) Wait added in v1.9.2

func (c *Core) Wait() error

type Ctx

type Ctx struct {
	context.Context
	W    ResponseWriter
	Resp http.ResponseWriter
	R    *http.Request

	Config *Options
	// contains filtered or unexported fields
}

func (*Ctx) Abort

func (c *Ctx) Abort(args ...interface{}) *Ctx

func (*Ctx) AbortJSON added in v0.0.2

func (c *Ctx) AbortJSON(data interface{}) error

func (*Ctx) AbortToJSON added in v0.0.2

func (c *Ctx) AbortToJSON(data interface{}, err error) error

func (*Ctx) Cookie

func (c *Ctx) Cookie(cookie *http.Cookie)

func (*Ctx) Cookies added in v0.0.3

func (c *Ctx) Cookies(name string) (string, error)

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) Core

func (c *Ctx) Core() *Core

func (*Ctx) File

func (c *Ctx) File(filepath string)

File writes the specified file into the body stream in an efficient way.

func (*Ctx) FileAttachment

func (c *Ctx) FileAttachment(filepath, filename string)

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) Flush

func (c *Ctx) Flush(data interface{}, statusCode ...int) error

Flush response dat and break

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

func (c *Ctx) FormValue(key string, def ...string) string

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

func (c *Ctx) FromValues(key string, def ...[]string) []string

FromValues returns a slice of strings for a given query key.

func (*Ctx) Get

func (c *Ctx) Get(key string) (val interface{}, ok bool)

Get returns the value for the given key, ie: (value, true). If the value does not exists it returns (nil, false)

func (*Ctx) GetAs

func (c *Ctx) GetAs(key string, v interface{}) error

GetAs retrieve struct like c.Get("user").(User)

> Experimental function, problem unknown

func (*Ctx) GetBool

func (c *Ctx) GetBool(key string) (value bool)

GetBool returns the value associated with the key as a boolean.

func (*Ctx) GetDuration

func (c *Ctx) GetDuration(key string) (d time.Duration)

GetDuration returns the value associated with the key as a duration.

func (*Ctx) GetFloat64

func (c *Ctx) GetFloat64(key string, def ...float64) (value float64)

GetFloat64 returns the value associated with the key as a float64.

func (*Ctx) GetHeader

func (c *Ctx) GetHeader(key string) string

GetHeader get request header

func (*Ctx) GetInt

func (c *Ctx) GetInt(key string, def ...int) (i int)

GetInt returns the value associated with the key as an integer.

func (*Ctx) GetInt64

func (c *Ctx) GetInt64(key string, def ...int64) (i int64)

GetInt64 returns the value associated with the key as an integer.

func (*Ctx) GetMap

func (c *Ctx) GetMap(key string, def ...map[string]interface{}) (value map[string]interface{})

GetMap returns the value associated with the key as a map of interfaces.

> return map[string]interface{}

func (*Ctx) GetMapString

func (c *Ctx) GetMapString(key string, def ...map[string]string) (value map[string]string)

GetMapString returns the value associated with the key as a map of strings.

> return map[string]string

func (*Ctx) GetMapStringSlice

func (c *Ctx) GetMapStringSlice(key string, def ...map[string][]string) (value map[string][]string)

GetStringMapStringSlice returns the value associated with the key as a map to a slice of strings.

> return map[string][]string

func (*Ctx) GetParam

func (c *Ctx) GetParam(k string, def ...string) string

GetParam get param

func (*Ctx) GetParamInt added in v1.9.31

func (c *Ctx) GetParamInt(k string, def ...int) int

GetParamInt get int param, return -1 if failed

func (*Ctx) GetParamUid added in v1.9.31

func (c *Ctx) GetParamUid(k string, def ...uid.UID) uid.UID

GetParamInt get int param, return uid.Nil if failed

func (*Ctx) GetStatus

func (c *Ctx) GetStatus() int

GetStatus get response statusCode

func (*Ctx) GetString

func (c *Ctx) GetString(key string, def ...string) (value string)

GetString returns the value associated with the key as a string.

func (*Ctx) GetStrings

func (c *Ctx) GetStrings(key string, def ...[]string) (value []string)

GetStrings String Slice returns the value associated with the key as a slice of strings.

func (*Ctx) GetTime

func (c *Ctx) GetTime(key string) (t time.Time)

GetTime returns the value associated with the key as time.

func (*Ctx) GetUint

func (c *Ctx) GetUint(key string, def ...uint) (i uint)

GetUint returns the value associated with the key as an integer.

func (*Ctx) GetUint64

func (c *Ctx) GetUint64(key string, def ...uint64) (i uint64)

GetUint64 returns the value associated with the key as an integer.

func (*Ctx) JSON

func (c *Ctx) JSON(data interface{}) error

func (*Ctx) JSONP

func (c *Ctx) JSONP(data interface{}, callback ...string) error

func (*Ctx) Method added in v0.0.2

func (c *Ctx) Method() string

func (*Ctx) Next

func (c *Ctx) Next()

func (*Ctx) Params

func (c *Ctx) Params() params

Params All params

func (*Ctx) Path added in v0.0.2

func (c *Ctx) Path() string

Path output path

func (*Ctx) ReadBody

func (c *Ctx) ReadBody(out interface{}) error

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) Redirect added in v1.9.7

func (c *Ctx) Redirect(to string, stCode ...int)

func (*Ctx) RedirectJS added in v1.9.7

func (c *Ctx) RedirectJS(to string, msg ...string)

func (*Ctx) RemoteIP

func (c *Ctx) RemoteIP() net.IP

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 (c *Ctx) RemoveCookie(name, path string, dom ...string)

func (*Ctx) Render added in v1.9.4

func (c *Ctx) Render(f string, bind ...interface{}) error

func (*Ctx) SaveFile

func (c *Ctx) SaveFile(key, dst string, args ...interface{}) (relpath, abspath string, err error)

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) SaveFiles added in v1.9.21

func (c *Ctx) SaveFiles(key, dst string, args ...any) (rel Array, err error)

func (*Ctx) Send

func (c *Ctx) Send(buf []byte) error

Send send []byte to client

func (*Ctx) SendStatus

func (c *Ctx) SendStatus(status int, msg ...string) error

SendStatus send status code

func (*Ctx) SendString

func (c *Ctx) SendString(str ...interface{}) error

SendString send string to client

func (*Ctx) Set

func (c *Ctx) Set(key string, val interface{})

func (*Ctx) SetCookie

func (c *Ctx) SetCookie(name, value string, exp time.Time, path string, args ...interface{})

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) SetHeader

func (c *Ctx) SetHeader(key, value string)

SetHeader set response header

func (*Ctx) SetParam

func (c *Ctx) SetParam(k, v string)

SetParam set param

func (*Ctx) Status

func (c *Ctx) Status(status int) *Ctx

Status WriteHeader status code

func (*Ctx) Stream

func (c *Ctx) Stream(step func(w io.Writer) bool) bool

Stream sends a streaming response and returns a boolean indicates "Is client disconnected in middle of stream"

func (*Ctx) ToJSON

func (c *Ctx) ToJSON(data interface{}, err error) error

func (*Ctx) Vars added in v1.9.18

func (c *Ctx) Vars() map[string]any

func (*Ctx) ViewReload added in v1.9.10

func (c *Ctx) ViewReload()

func (*Ctx) ViewTheme added in v1.9.4

func (c *Ctx) ViewTheme(theme string)

ViewTheme 使用模版风格

type DB added in v0.0.2

type DB = gorm.DB

func Conn added in v0.0.2

func Conn() *DB

func NewModel added in v0.0.2

func NewModel(conf Options, debug, colorful bool) (*DB, error)

func Where added in v0.0.2

func Where(whr *Map, db ...*DB) (*DB, int, int)

Where build page query

whr *Map
db  *DB optional
return *DB, pos, lmt

type Engine added in v1.9.0

type Engine struct {
	*Core

	Ctx context.Context
	EG  *errgroup.Group
	// contains filtered or unexported fields
}

func NewEngine added in v1.9.0

func NewEngine(conf ...Options) *Engine

func (*Engine) ListenAndServe added in v1.9.0

func (e *Engine) ListenAndServe(addr ...string) error

func (*Engine) ListenAndServeTLS added in v1.9.8

func (e *Engine) ListenAndServeTLS(cert, key string) error

func (*Engine) Serve added in v1.9.0

func (e *Engine) Serve(ln net.Listener) error

func (*Engine) Shutdown added in v1.9.0

func (e *Engine) Shutdown() error

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

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error represents an error that occurred while handling a request.

func NewError

func NewError(code int, message ...string) *Error

NewError creates a new Error instance with an optional message

func (*Error) Error

func (e *Error) Error() string

Error makes it compatible with the `error` interface.

type Handler

type Handler struct {
	Handlers map[string]struct{} // Record callable handle

	ID string
	// contains filtered or unexported fields
}

Handler base Handler

func (*Handler) Core

func (h *Handler) Core(c ...*Core) *Core

Core get or set Core

func (*Handler) HandName

func (h *Handler) HandName(name ...string) string

func (*Handler) Init

func (h *Handler) Init()

Init do nothing wait children rewrite app start call this func

func (*Handler) Prefix

func (h *Handler) Prefix(prefix ...string) string

Prefix set or get prefix e.g h.Prefix("/api")

func (*Handler) Preload

func (h *Handler) Preload(c *Ctx)

Preload do nothing wait children rewrite any request before call this func

func (*Handler) PushHandler

func (h *Handler) PushHandler(method, path string)

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.

func (*InmemoryListener) Dial

func (ln *InmemoryListener) Dial() (net.Conn, error)

Dial creates new client<->server connection. Just like a real Dial it only returns once the server has accepted the connection.

It is safe calling Dial from concurrently running goroutines.

type InvalidUnmarshalError

type InvalidUnmarshalError struct {
	Type reflect.Type
}

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 LoggerConfig struct {
	ForceColor bool
	Output     io.Writer
}

type Map added in v0.0.2

type Map map[string]interface{}

Map map[string]interface{}

func (Map) GetBool added in v0.0.5

func (d Map) GetBool(k string) (value bool)

func (Map) GetString added in v0.0.5

func (d Map) GetString(k string) (value string)

func (Map) GormDataType added in v0.0.3

func (Map) GormDataType() string

GormDataType schema.Field DataType

func (*Map) Scan added in v0.0.3

func (d *Map) Scan(src interface{}) error

Scan 数据驱动接口

func (Map) ToString added in v1.9.4

func (d Map) ToString(k string, def ...string) string

func (Map) Value added in v0.0.3

func (d Map) Value() (driver.Value, error)

Value 数据驱动接口

type Mod added in v1.9.32

type Mod interface {
	Init()
}

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

func (m *Model) BeforeCreate(tx *DB) error

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

func (m *Models) BeforeCreate(tx *DB) error

type Module added in v1.9.0

type Module interface {
	Module() ModuleInfo
}

type ModuleInfo added in v1.9.0

type ModuleInfo struct {
	ID       string
	Instance func() Mod
}

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 NextPages struct {
	P    int  `json:"p"`
	L    int  `json:"l"`
	Next bool `json:"next"`
	Prev bool `json:"prev"`
	Data any  `json:"data"`
}

func FindNext added in v1.9.34

func FindNext(whr *Map, out any, db ...*DB) (result NextPages, err error)

type NotFoundFunc added in v1.9.14

type NotFoundFunc func(*Ctx, error)

NotFoundFunc Handle

type Options added in v1.9.1

type Options map[string]interface{}
var (
	Conf Options
)

func LoadConfigFile

func LoadConfigFile(file string, opts ...Options) Options

func (*Options) GetAs added in v1.9.4

func (c *Options) GetAs(k string, v interface{}) error

func (*Options) GetBool added in v1.9.1

func (c *Options) GetBool(k string, def ...bool) bool

func (*Options) GetInt added in v1.9.1

func (c *Options) GetInt(k string, def ...int) int

func (*Options) GetInt64 added in v1.9.1

func (c *Options) GetInt64(k string, def ...int64) int64

func (*Options) GetMap added in v1.9.1

func (c *Options) GetMap(k string, def ...Options) Options

func (*Options) GetString added in v1.9.1

func (c *Options) GetString(k string, def ...string) string

func (*Options) GetStrings added in v1.9.1

func (c *Options) GetStrings(k string, def ...[]string) []string

func (*Options) ToString added in v1.9.1

func (c *Options) ToString(k string, def ...string) string

func (*Options) Value added in v1.9.1

func (c *Options) Value(k string) (interface{}, bool)

type Pages added in v0.0.2

type Pages struct {
	P     int   `json:"p"`
	L     int   `json:"l"`
	Total int64 `json:"total"`
	Data  any   `json:"data"`
	Extra any   `json:"extra,omitempty"`
}

func FindPage added in v0.0.3

func FindPage(whr *Map, out interface{}, db ...*DB) (result Pages, err error)

FindPage Gorm find to page process whr

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!

func (*PipeConns) Close

func (pc *PipeConns) Close() error

Close closes pipe connections.

func (*PipeConns) Conn1

func (pc *PipeConns) Conn1() net.Conn

Conn1 returns the first end of bi-directional pipe.

Data written to Conn1 may be read from Conn2. Data written to Conn2 may be read from Conn1.

func (*PipeConns) Conn2

func (pc *PipeConns) Conn2() net.Conn

Conn2 returns the second end of bi-directional pipe.

Data written to Conn2 may be read from Conn1. Data written to Conn1 may be read from Conn2.

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

func (StringOrNil) Value added in v0.0.2

func (s StringOrNil) Value() (driver.Value, error)

implements driver.Valuer, will be invoked automatically when written to the db

type TextEngine added in v1.9.11

type TextEngine struct {
	Templates *template.Template
	// contains filtered or unexported fields
}

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) Execute added in v1.9.11

func (ve *TextEngine) Execute(out io.Writer, tpl string, binding interface{}, layout ...string) error

func (*TextEngine) Layout added in v1.9.11

func (ve *TextEngine) Layout(layout string) *TextEngine

func (*TextEngine) Load added in v1.9.11

func (ve *TextEngine) Load() error

Load load tmpl file

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

type UUID struct {
	uuid.UUID
}

func NewUUID added in v1.9.33

func NewUUID() UUID

func UUIDFromString added in v1.9.33

func UUIDFromString(s string) (UUID, error)

func (UUID) IsEmpty added in v1.9.33

func (u UUID) IsEmpty() bool

func (UUID) ToString added in v1.9.33

func (u UUID) ToString() string

type ViewEngine added in v1.9.4

type ViewEngine struct {
	Templates *template.Template
	// contains filtered or unexported fields
}

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) Execute added in v1.9.4

func (ve *ViewEngine) Execute(out io.Writer, tpl string, binding interface{}, layout ...string) error

func (*ViewEngine) Layout added in v1.9.4

func (ve *ViewEngine) Layout(layout string) *ViewEngine

func (*ViewEngine) Load added in v1.9.4

func (ve *ViewEngine) Load() error

Load load tmpl file

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

type Views added in v1.9.4

type Views interface {
	Theme(string)
	DoTheme(string)
	Execute(out io.Writer, tpl string, binding interface{}, layout ...string) error
	AddFunc(name string, fn interface{}) Views
	SetReload()
}

func NewTextView added in v1.9.11

func NewTextView(directory, ext string, args ...interface{}) Views

type Writers added in v1.9.24

type Writers struct{}

func (Writers) Printf added in v1.9.24

func (Writers) Printf(f string, args ...interface{})

Directories

Path Synopsis
examples
mvc
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:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL