Documentation
¶
Index ¶
- func InitGagaMimes()
- func StaticFileController(r *Request, prefix string, dir string, compress bool) string
- type Config
- type Controller
- type DatabaseConfig
- type Gaga
- type LogConfig
- type Request
- type Resource
- type Response
- type Route
- type Routing
- func (r *Routing) Any(path string, controller Controller) *Route
- func (r *Routing) CreateRoute(method string, path string, controller Controller) *Route
- func (r *Routing) Delete(path string, controller Controller) *Route
- func (r *Routing) Get(path string, controller Controller) *Route
- func (r *Routing) Head(path string, controller Controller) *Route
- func (r *Routing) Options(path string, controller Controller) *Route
- func (r *Routing) Patch(path string, controller Controller) *Route
- func (r *Routing) Post(path string, controller Controller) *Route
- func (r *Routing) Put(path string, controller Controller) *Route
- func (r *Routing) Static(path string, dir string)
- func (r *Routing) Trace(path string, controller Controller) *Route
- type SEOConfig
- type ServerConfig
- type Template
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitGagaMimes ¶
func InitGagaMimes()
Types ¶
type Config ¶
type Config struct { Server ServerConfig `json:"server"` Database interface{} `json:"database,omitempty"` Log LogConfig `json:"log,omitempty"` SEO SEOConfig `json:"seo,omitempty"` Custom interface{} `json:"custom,omitempty"` }
Config is the main configuration struct
func LoadConfig ¶
func LoadConfig() *Config
LoadConfig loads Gaga configurations from the specified file. It automatically allows environment overrides for dev and production as well as for different users on a device.
type Controller ¶
type DatabaseConfig ¶
type DatabaseConfig struct { Engine string `json:"engine"` Host string `json:"host"` Port int `json:"port,omitempty"` Username string `json:"username,omitempty"` Password string `json:"password,omitempty"` }
DatabaseConfig configuration struct
type Gaga ¶
type Gaga struct { Config *Config RouteGenerator func(*Routing) NotFoundHandler func(*Request) string }
Gaga main struct
type LogConfig ¶
type LogConfig struct { // Engine is the device to log into. // // Options include: // file, console, both Engine string `json:"engine"` Path string `json:"path,omitempty"` ShowSource bool `json:"show_source,omitempty"` // Level is the minimum log level to show. // // Options include: // info, error, warn, trace, fatal, panic. Level string `json:"level,omitempty"` }
LogConfig configuration struct
type Request ¶
type Request struct { URI string Method string Header map[string]string Params map[string]string Response Response Writer http.ResponseWriter BaseRequest *http.Request // contains filtered or unexported fields }
Request struct
type Resource ¶
type Resource interface { Create(r *Request) Update(r *Request) Delete(r *Request) View(r *Request) }
Resource interface is a form of controller that allows you to automatically create and bind CRUD operations to related methods in structs as well as automatically create related and useful routing.
type Route ¶
type Route struct { Path string Controller Controller // contains filtered or unexported fields }
Route struct
type Routing ¶
Routing struct
func (*Routing) Any ¶
func (r *Routing) Any(path string, controller Controller) *Route
Any allows creation of a route that's bound to all/any request method.
func (*Routing) CreateRoute ¶
func (r *Routing) CreateRoute(method string, path string, controller Controller) *Route
CreateRoute allows you to create a route for any HTTP method bound to a given path.
func (*Routing) Delete ¶
func (r *Routing) Delete(path string, controller Controller) *Route
Delete routes an HTTP DELETE request with a request URI matching the given path to the given controller.
func (*Routing) Get ¶
func (r *Routing) Get(path string, controller Controller) *Route
Get routes an HTTP GET request with a request URI matching the given path to the given controller.
func (*Routing) Head ¶
func (r *Routing) Head(path string, controller Controller) *Route
Head routes an HTTP HEAD request with a request URI matching the given path to the given controller.
func (*Routing) Options ¶
func (r *Routing) Options(path string, controller Controller) *Route
Options routes an HTTP OPTIONS request with a request URI matching the given path to the given controller.
func (*Routing) Patch ¶
func (r *Routing) Patch(path string, controller Controller) *Route
Patch routes an HTTP PATCH request with a request URI matching the given path to the given controller.
func (*Routing) Post ¶
func (r *Routing) Post(path string, controller Controller) *Route
Post routes an HTTP POSt request with a request URI matching the given path to the given controller.
func (*Routing) Put ¶
func (r *Routing) Put(path string, controller Controller) *Route
Put routes an HTTP PUT request with a request URI matching the given path to the given controller.
type SEOConfig ¶
type SEOConfig struct { // Compress indicates whether to compress output. // The output is only compressed when the requester (most likely // a browser supports it through the Accept-Encoding header. // // gzip is the default if supported, if not, // deflate will be attempted if supported. Compress bool `json:"compress,omitempty"` // CompressionThreshold is the minimum response size before // response compression sets in for non static files. // // NOTE: // // 1. Once compression is enabled, all static files will be // compressed if the request supports it. // // 2. For very light data (few bytes), compression may increase the // size of the response. CompressionThreshold int `json:"compression_threshold,omitempty"` }
SEOConfig configuration struct