Documentation ¶
Overview ¶
-*- indent-tabs-mode:nil; coding: utf-8 -*- * Copyleft (C) 2015 * "Tag bao" known as "wackonline" <[email protected]> * Goway is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License and GNU * Lesser General Public License published by the Free Software * Foundation, either version 3 of the License, or (at your option) * any later version. * Goway is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License and GNU Lesser General Public License * for more details. * You should have received a copy of the GNU General Public License * and GNU Lesser General Public License along with this program. * If not, see <http://www.gnu.org/licenses/>.
-*- Indent-tabs-mode:nil; coding: utf-8 -*- * Copyleft (C) 2015 * "Tag bao" known as "wackonline" <[email protected]> * Goway is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License and GNU * Lesser General Public License published by the Free Software * Foundation, either version 3 of the License, or (at your option) * any later version. * Goway is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License and GNU Lesser General Public License * for more details. * You should have received a copy of the GNU General Public License * and GNU Lesser General Public License along with this program. * If not, see <http://www.gnu.org/licenses/>.
Index ¶
- Constants
- Variables
- func InterfaceOf(value interface{}) reflect.Type
- type ClassicGoway
- type Config
- type Context
- type Goway
- type Handler
- type Injector
- type Logger
- type Logs
- func (lg *Logs) Error(str string, a ...interface{})
- func (lg *Logs) IsLogger(v int) bool
- func (lg *Logs) Notice(str string, a ...interface{})
- func (lg *Logs) Print()
- func (lg *Logs) Setloglevel(lv string)
- func (lg *Logs) StartLogger() Handler
- func (lg *Logs) Strict(str string, a ...interface{})
- func (lg *Logs) Use(lgs []Tlogs)
- func (lg *Logs) Warning(str string, a ...interface{})
- type ResponseWriter
- type ReturnHandler
- type Router
- type Routes
- func (r *Routes) AddRouter(method string, pattern string, handler Handler)
- func (r *Routes) Any(pattern string, handler Handler)
- func (r *Routes) Delete(pattern string, handler Handler)
- func (r *Routes) Get(pattern string, handler Handler)
- func (routes *Routes) Handler(w http.ResponseWriter, r *http.Request, c Context)
- func (routes *Routes) Match(method string, route *router, r *http.Request) (bool, Handler)
- func (r *Routes) NotFound(handler Handler)
- func (r *Routes) Patch(pattern string, handler Handler)
- func (r *Routes) Post(pattern string, handler Handler)
- func (r *Routes) Put(pattern string, handler Handler)
- func (r *Routes) Static(pattern string, dir string)
- type Tlogs
Constants ¶
const ( CONFIGFILE = "/conf/config.json" HTTPSERVER = "0.0.0.0" PORT = "8080" ENV = "development" DEBUG = true LOGGER = "E_ALL" STATICPATH = "/public" VERSION = "0.0.1" )
const ( //E_ALL = 1 E_ERROR = 1 E_WARNING = 2 E_STRICT = 4 E_NOTICE = 8 )
const ( CONNECT = "CONNECT" DELETE = "DELETE" GET = "GET" HEAD = "HEAD" OPTIONS = "OPTIONS" PATCH = "PATCH" POST = "POST" PUT = "PUT" TRACE = "TRACE" ANY = "*" )
Variables ¶
var Params map[string]string
Functions ¶
func InterfaceOf ¶
Types ¶
type ClassicGoway ¶
func Bootstrap ¶
func Bootstrap() *ClassicGoway
type Config ¶
type Goway ¶
type Goway struct { Injector // contains filtered or unexported fields }
func (*Goway) ServeHTTP ¶
func (g *Goway) ServeHTTP(w http.ResponseWriter, r *http.Request)
Type conversion (*Context)(nil) and (*http.ResponseWriter)(nil):
As (* interface{})(nil) Will be nil to the pointer to the interface type
function NewResponseWriter:
It is to implement the HTTP package ResponseWriter interface
type Handler ¶
type Handler interface{}
To accept the custom function Example:
goway.Get("/",function(){ //this function is Handler })
The func() is Handler
type Injector ¶
type Logger ¶
type Logs ¶
type Logs struct {
// contains filtered or unexported fields
}
func (*Logs) IsLogger ¶
Determine whether excluded set log level Example:
all := A|B|C|D|E all & C not eq 0 (C in ALL) all1 := A|B|C all1 & D eq 0 (D not in ALL)
func (*Logs) Setloglevel ¶
Excluded error message is set to false
func (*Logs) StartLogger ¶
type ResponseWriter ¶
type ResponseWriter interface { Header() http.Header Write([]byte) (int, error) WriteHeader(int) IsWrite() bool Status() int Size() int }
func NewResponseWriter ¶
func NewResponseWriter(rw http.ResponseWriter) ResponseWriter
Created an new ResponseWriter
type ReturnHandler ¶
type Router ¶
type Router interface { Get(pattern string, handler Handler) // Patch adds a route for a HTTP PATCH request to the specified matching pattern. Patch(string, Handler) // Post adds a route for a HTTP POST request to the specified matching pattern. Post(string, Handler) // Put adds a route for a HTTP PUT request to the specified matching pattern. Put(string, Handler) // Delete adds a route for a HTTP DELETE request to the specified matching pattern. Delete(string, Handler) // Any adds a route for any HTTP method request to the specified matching pattern. Any(string, Handler) // AddRoute adds a route for a given HTTP method request to the specified matching pattern. Static(string, string) NotFound(handlers Handler) }
type Routes ¶
type Routes struct {
// contains filtered or unexported fields
}