wega

package module
v0.0.0-...-c5e8a93 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2019 License: MIT Imports: 18 Imported by: 0

README

wega

Web Golang API framework with ORM

Documentation

Index

Constants

View Source
const (
	MimeApplicationJSON                  = "application/json"
	MimeApplicationJSONCharsetUTF8       = MimeApplicationJSON + "; " + CharsetUTF8
	MimeApplicationJavaScript            = "application/javascript"
	MimeApplicationJavaScriptCharsetUTF8 = MimeApplicationJavaScript + "; " + CharsetUTF8
	MimeApplicationXML                   = "application/xml"
	MimeApplicationXMLCharsetUTF8        = MimeApplicationXML + "; " + CharsetUTF8
	MimeTextXML                          = "text/xml"
	MimeTextXMLCharsetUTF8               = MimeTextXML + "; " + CharsetUTF8
	MimeApplicationForm                  = "application/x-www-form-urlencoded"
	MimeApplicationProtobuf              = "application/protobuf"
	MimeApplicationMsgpack               = "application/msgpack"
	MimeTextHTML                         = "text/html"
	MimeTextHTMLCharsetUTF8              = MimeTextHTML + "; " + CharsetUTF8
	MimeTextPlain                        = "text/plain"
	MimeTextPlainCharsetUTF8             = MimeTextPlain + "; " + CharsetUTF8
	MimeMultipartForm                    = "multipart/form-data"
	MimeOctetStream                      = "application/octet-stream"
)

Mime types

View Source
const (
	HeaderAccept              = "Accept"
	HeaderAcceptEncoding      = "Accept-Encoding"
	HeaderAllow               = "Allow"
	HeaderAuthorization       = "Authorization"
	HeaderContentDisposition  = "Content-Disposition"
	HeaderContentEncoding     = "Content-Encoding"
	HeaderContentLength       = "Content-Length"
	HeaderContentType         = "Content-Type"
	HeaderCookie              = "Cookie"
	HeaderSetCookie           = "Set-Cookie"
	HeaderIfModifiedSince     = "If-Modified-Since"
	HeaderLastModified        = "Last-Modified"
	HeaderLocation            = "Location"
	HeaderUpgrade             = "Upgrade"
	HeaderVary                = "Vary"
	HeaderWWWAuthenticate     = "WWW-Authenticate"
	HeaderXForwardedFor       = "X-Forwarded-For"
	HeaderXForwardedProto     = "X-Forwarded-Proto"
	HeaderXForwardedProtocol  = "X-Forwarded-Protocol"
	HeaderXForwardedSsl       = "X-Forwarded-Ssl"
	HeaderXUrlScheme          = "X-Url-Scheme"
	HeaderXHTTPMethodOverride = "X-HTTP-Method-Override"
	HeaderXRealIP             = "X-Real-IP"
	HeaderXRequestID          = "X-Request-ID"
	HeaderXRequestedWith      = "X-Requested-With"
	HeaderServer              = "Server"
	HeaderOrigin              = "Origin"

	HeaderAccessControlRequestMethod    = "Access-Control-Request-Method"
	HeaderAccessControlRequestHeaders   = "Access-Control-Request-Headers"
	HeaderAccessControlAllowOrigin      = "Access-Control-Allow-Origin"
	HeaderAccessControlAllowMethods     = "Access-Control-Allow-Methods"
	HeaderAccessControlAllowHeaders     = "Access-Control-Allow-Headers"
	HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials"
	HeaderAccessControlExposeHeaders    = "Access-Control-Expose-Headers"
	HeaderAccessControlMaxAge           = "Access-Control-Max-Age"

	HeaderStrictTransportSecurity = "Strict-Transport-Security"
	HeaderXContentTypeOptions     = "X-Content-Type-Options"
	HeaderXXSSProtection          = "X-XSS-Protection"
	HeaderXFrameOptions           = "X-Frame-Options"
	HeaderContentSecurityPolicy   = "Content-Security-Policy"
	HeaderXCSRFToken              = "X-CSRF-Token"
)

Header types

View Source
const (
	CharsetUTF8 = "charset=UTF-8"
)

charsets

Variables

This section is empty.

Functions

func CommandRun

func CommandRun(app *App, args []string) error

Types

type App

type App struct {
	Debug bool

	Server *http.Server
	Listen string

	Router *Router
	Layers []Layer

	Databases map[string]Database

	Caches map[string]Cache

	Commands map[string]Command

	RouteNotFound            View
	RouteMethodNotAllowed    View
	RouteInternalServerError View
	// contains filtered or unexported fields
}

func (*App) Run

func (app *App) Run() error

func (*App) RunFromCommandArgs

func (app *App) RunFromCommandArgs(args []string) error

type Cache

type Cache interface {
	Connection() CacheConnection
}

type CacheConfig

type CacheConfig struct {
	Name    string
	Timeout time.Duration
}

type CacheConnection

type CacheConnection interface {
	Get(key string) (string, bool)
	Set(key string, val string, expiration time.Duration) bool
	GetJSON(key string, obj interface{}) bool
	SetJSON(key string, obj interface{}, expiration time.Duration) bool
}

type Command

type Command func(app *App, args []string) error

type Context

type Context interface {
	http.ResponseWriter

	ResponseWriter() http.ResponseWriter

	App() *App
	Request() *contextRequest

	DB(names ...string) *sql.DB
	Cache(names ...string) CacheConnection

	SetCookie(*http.Cookie)

	StatusCode() int
	StatusPass() error
	Status(code int) error
	StatusText(code int) error
	Bytes(code int, data []byte) error
	String(code int, text string) error
	Redirect(code int, toURL string) error
	HTML(code int, html string) error
	Template(code int, tmpl *template.Template, data interface{}) error
	TemplateFile(code int, filename string, data interface{}) error
	JSON(code int, obj interface{}) error
	Stream(contentType string, code int, r io.Reader) error
	File(filename string) error
	Error(message ...string) error
	NotFound() error
	BadRequest() error
	// contains filtered or unexported methods
}

type Database

type Database interface {
	Connection() *sql.DB
}

type Layer

type Layer interface {
	Process(View) View
}

type Router

type Router struct {
	Methods map[string]View
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter() *Router

func (*Router) Add

func (r *Router) Add(path string, view View, methods ...string) *Router

func (*Router) Match

func (r *Router) Match(ctx Context) View

func (*Router) Set

func (r *Router) Set(route *Router) *Router

type View

type View func(Context) error

func Cached

func Cached(view View, config *CacheConfig) View

func FileServer

func FileServer(filePath ...string) View

Directories

Path Synopsis
cache module
db module
future
ht

Jump to

Keyboard shortcuts

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