Documentation ¶
Index ¶
- Constants
- func PrintRouter(r *router)
- type CORS
- type Config
- func (f Config) CRUD(path string, h ...HandlerFunc) Resource
- func (f Config) Config() *Config
- func (f Config) DELETE(path string, handler HandlerFunc) Handler
- func (f Config) GET(path string, handler HandlerFunc) Handler
- func (f Config) Group(path string) Group
- func (f Config) OPTIONS(path string, handler HandlerFunc) Handler
- func (f Config) PATCH(path string, handler HandlerFunc) Handler
- func (f Config) POST(path string, handler HandlerFunc) Handler
- func (f Config) PUT(path string, handler HandlerFunc) Handler
- func (f Config) STATIC(static map[string]string)
- func (f Config) Start() error
- func (f Config) Stop() error
- func (f Config) TRACE(path string, handler HandlerFunc) Handler
- func (f Config) WS(path string, handler HandlerFunc) Handler
- type Context
- type Filter
- type Fresh
- type Group
- type Gzip
- type Handler
- type HandlerFunc
- type Limit
- type Logs
- type Request
- type Resource
- type Response
- type Rest
- type Router
- type Security
- type TSL
Constants ¶
View Source
const ( MIMEAppJSON = "application/json" + ";" + UTF8 MIMEAppJS = "application/javascript" + ";" + UTF8 MIMEAppXML = "application/xml" + ";" + UTF8 MIMEUrlencoded = "application/x-www-form-urlencoded" MIMEMultipart = "multipart/form-data" MIMETextHTML = "text/html" + ";" + UTF8 MIMETextXML = "text/xml" + ";" + UTF8 MIMEText = "text/plain" + ";" + UTF8 MIMEGzip = "gzip" )
MIME types
View Source
const ( AccessControlMaxAge = "Access-Control-Max-Age" AccessControlAllowOrigin = "Access-Control-Allow-Origin" AccessControlAllowMethods = "Access-Control-Allow-Methods" AccessControlAllows = "Access-Control-Allow-s" AccessControlRequestMethod = "Access-Control-Request-Method" AccessControlExposes = "Access-Control-Expose-s" AccessControlRequests = "Access-Control-Request-s" AccessControlAllowCredentials = "Access-Control-Allow-Credentials" AccessControlAllowHeaders = "Access-Control-Allow-Headers" )
Access
View Source
const ( Accept = "Accept" AcceptEncoding = "Accept-Encoding" Allow = "Allow" Authorization = "Authorization" ContentDisposition = "Content-Disposition" ContentEncoding = "Content-Encoding" ContentLength = "Content-Length" ContentType = "Content-Type" Cookie = "Cookie" SetCookie = "Set-Cookie" IfModifiedSince = "If-Modified-Since" LastModified = "Last-Modified" Location = "Location" Upgrade = "Upgrade" Vary = "Vary" WWWAuthenticate = "WWW-Authenticate" XForwardedFor = "X-Forwarded-For" XForwardedProto = "X-Forwarded-Proto" XForwardedProtocol = "X-Forwarded-Protocol" XForwardedSsl = "X-Forwarded-Ssl" XUrlScheme = "X-Url-Scheme" XHTTPMethodOverride = "X-HTTP-Method-Override" XRealIP = "X-Real-IP" XRequestID = "X-Request-ID" Server = "Server" Origin = "Origin" )
Request
View Source
const ( UTF8 = "charset=UTF-8" ISO88591 = "chartset=ISO-8859-1" )
Encoding chartset
View Source
const ( B = 1 << (10 * iota) K M G T )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CORS ¶
type CORS struct { Origins []string `yaml:"origins,omitempty"` Methods []string `yaml:"methods,omitempty"` Headers []string `yaml:"headers,omitempty"` Expose []string `yaml:"expose,omitempty"` MaxAge int `yaml:"maxage,omitempty"` Credentials bool `yaml:"credentials,omitempty"` Filters []Filter `yaml:"-,omitempty"` }
type Config ¶
type Config struct { Host string `yaml:"host,omitempty"` // server host Port int `yaml:"port,omitempty"` // server port Logs Logs `yaml:"logs,omitempty"` // server logs TSL *TSL `yaml:"tsl,omitempty"` // tsl options Gzip *Gzip `yaml:"gzip,omitempty"` // gzip Config CORS *CORS `yaml:"cors,omitempty"` // cors options Limit *Limit `yaml:"limit,omitempty"` // limit options Default []string `yaml:"default,omitempty"` // default static files (index.html or main.html and so on) Statics map[string]string `yaml:"static,omitempty"` // serve static files Banner bool `yaml:"banner,omitempty"` // enable / disable startup banner Options bool `yaml:"options,omitempty"` // accept all OPTIONS requests Router *Router `yaml:"router,omitempty"` // router related config // contains filtered or unexported fields }
func (Config) CRUD ¶
func (f Config) CRUD(path string, h ...HandlerFunc) Resource
Register a resource (get, post, put, delete)
func (Config) DELETE ¶
func (f Config) DELETE(path string, handler HandlerFunc) Handler
DELETE api registration
func (Config) GET ¶
func (f Config) GET(path string, handler HandlerFunc) Handler
GET api registration
func (Config) OPTIONS ¶
func (f Config) OPTIONS(path string, handler HandlerFunc) Handler
OPTIONS api registration
func (Config) PATCH ¶
func (f Config) PATCH(path string, handler HandlerFunc) Handler
PATCH api registration
func (Config) POST ¶
func (f Config) POST(path string, handler HandlerFunc) Handler
POST api registration
func (Config) PUT ¶
func (f Config) PUT(path string, handler HandlerFunc) Handler
PUT api registration
func (Config) STATIC ¶
ASSETS serve a list of static files. Array of files or directories TODO write logic
func (Config) TRACE ¶
func (f Config) TRACE(path string, handler HandlerFunc) Handler
TRACE api registration
type Context ¶
type Context interface { Request() Request Response() Response Writer(http.ResponseWriter) }
Main Fresh structure
type Group ¶
type Group interface { Rest Group(string) Group After(...HandlerFunc) Group Before(...HandlerFunc) Group }
type Gzip ¶
type Handler ¶
type Handler interface { After(...HandlerFunc) Handler Before(...HandlerFunc) Handler }
Handler struct
type Request ¶
type Request interface { IsWS() bool IsTSL() bool Auth() string AuthBearer() string URL() *url.URL Method() string Header() http.Header JSON(interface{}) error JSONraw() map[string]interface{} Form() url.Values Get() *http.Request WS() *websocket.Conn Body() io.ReadCloser QueryString() string SetWS(*websocket.Conn) RouteParam(string) string FormValue(string) string QueryParam(string) string // contains filtered or unexported methods }
Request structure
type Resource ¶
type Resource interface { After(...HandlerFunc) Resource Before(...HandlerFunc) Resource }
type Response ¶
type Response interface { Code(int) error Type(content string) Raw(int, string) error Error(int, error) error HTML(int, string) error File(int, string) error Get() http.ResponseWriter Download(int, string) error XML(int, interface{}) error Text(int, interface{}) error JSON(int, interface{}) error JSONP(int, string, interface{}) error XMLFormat(int, interface{}, string) error JSONFormat(int, interface{}, string) error JSONPFormat(int, string, interface{}, string) error // contains filtered or unexported methods }
type Rest ¶
type Rest interface { STATIC(map[string]string) WS(string, HandlerFunc) Handler GET(string, HandlerFunc) Handler POST(string, HandlerFunc) Handler PUT(string, HandlerFunc) Handler TRACE(string, HandlerFunc) Handler PATCH(string, HandlerFunc) Handler DELETE(string, HandlerFunc) Handler OPTIONS(string, HandlerFunc) Handler CRUD(string, ...HandlerFunc) Resource }
type Security ¶
type Security struct { XSS string `yaml:"xss,omitempty"` HSTS int `yaml:"hsts,omitempty"` XDNS bool `yaml:"x-dns,omitempty"` CSFR string `yaml:"csfr,omitempty"` XFrame string `yaml:"x-frame,omitempty"` XContentType string `yaml:"x-content-type,omitempty"` ReferrerPolicy string `yaml:"referrer-policy,omitempty"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.