Documentation
¶
Index ¶
- Constants
- Variables
- func Default404Cacher(req Request, res Response)
- func DefaultCacher(req Request, res Response, thePanic interface{})
- func LaunchServer(addr string, r Router) error
- func SetGEnv(theme string)
- func SetPreCGurgling(obj *Gurgling_Config)
- type Cattail
- type Dump
- type Gurgling_Config
- type Hopper
- type IMidware
- type Midware
- type OriRequest
- func (this *OriRequest) BaseUrl() string
- func (this *OriRequest) Body() Tout
- func (this *OriRequest) F() map[string]Tout
- func (this *OriRequest) Get(key string) string
- func (this *OriRequest) GetAll(key string) []string
- func (this *OriRequest) Hostname() string
- func (this *OriRequest) Method() string
- func (this *OriRequest) OriginalPath() string
- func (this *OriRequest) Path() string
- func (this *OriRequest) Query() map[string]string
- func (this *OriRequest) R() *http.Request
- func (this *OriRequest) Referer() string
- type OriResponse
- func (this *OriResponse) F() map[string]Tout
- func (this *OriResponse) Get(key string) string
- func (this *OriResponse) JSON(obj interface{}) error
- func (this *OriResponse) JSONEx(obj interface{}, code int) error
- func (this *OriResponse) R() http.ResponseWriter
- func (this *OriResponse) Redirect(newAddr string) error
- func (this *OriResponse) RedirectEX(newAddr string, code int) error
- func (this *OriResponse) Send(content string) error
- func (this *OriResponse) SendCode(code int) error
- func (this *OriResponse) SendFile(filepath string) error
- func (this *OriResponse) SendFileEx(filepath string, mime string, encoder encoding.Encoder, httpCode int) error
- func (this *OriResponse) Set(key string, val string) error
- func (this *OriResponse) Status(content string, code int) error
- func (this *OriResponse) Write(content []byte) (int, error)
- type Request
- type Response
- type Router
- type RouterErrorCatcher
- type Sandwich
- type Terminal
Constants ¶
View Source
const (
RKEY_LOW_LAYER_R = "__low_layer_r"
)
Variables ¶
View Source
var ( ID_FOR_PREDEFINED_DEBUG = "predefined_debug" ID_FOR_PREDEFINED_RELEASE = "predefined_release" )
View Source
var ( CGurgling_Predefined_forDebug = &Gurgling_Config{ F: map[string]Tout{}, H500: nil, H404: nil, ID: ID_FOR_PREDEFINED_DEBUG, } CGurgling_Predefined_forRelease = &Gurgling_Config{ F: map[string]Tout{}, H500: DefaultCacher, H404: Default404Cacher, ID: ID_FOR_PREDEFINED_RELEASE, } )
View Source
var ( // Respose errors: RES_HEAD_ALREADY_SENT = errors.New("The response header has been sent.") SENDFILE_ENCODER_NOT_READY = errors.New("Encoder fails to create IO.") SENDFILE_FILEPATH_ERROR = errors.New("File path error.") JSON_STRINGIFY_ERROR = errors.New("Error while stringifying json.") SENT_BUT_ABORT = errors.New("Aborted due to error.") // Router errors: INVALID_MOUNT_POINT = errors.New("The mountpoint specified is not valid.") INVALID_RULE = errors.New("The match rule specified is not valid.") INVALID_INVALID_USE = errors.New("Used object could only be Terminal/Midware/Router/IMidware.") INVALID_PARAMETER = errors.New("Invalid parameter list.") SANDWICH_MOUNT_ERROR = errors.New("Sandwich could only be mounted to / in non-strict mode. (Try Router.Use(Sandwich))") )
View Source
var CGurgling = initPreCGurgling(CGurgling_Predefined_forDebug)
Functions ¶
func Default404Cacher ¶
func DefaultCacher ¶
func LaunchServer ¶
func SetPreCGurgling ¶
func SetPreCGurgling(obj *Gurgling_Config)
Types ¶
type Gurgling_Config ¶
type Midware ¶
The followings are mountable: ===================================================== Midware is a handler that could modify anything and make the data flow continue by returning manipulated Req, Res and true. otherwise return false and the Res/Req is not specified.
type OriRequest ¶
type OriRequest struct {
// contains filtered or unexported fields
}
func (*OriRequest) BaseUrl ¶
func (this *OriRequest) BaseUrl() string
func (*OriRequest) Body ¶
func (this *OriRequest) Body() Tout
func (*OriRequest) F ¶
func (this *OriRequest) F() map[string]Tout
func (*OriRequest) Get ¶
func (this *OriRequest) Get(key string) string
func (*OriRequest) GetAll ¶
func (this *OriRequest) GetAll(key string) []string
func (*OriRequest) Hostname ¶
func (this *OriRequest) Hostname() string
func (*OriRequest) Method ¶
func (this *OriRequest) Method() string
func (*OriRequest) OriginalPath ¶
func (this *OriRequest) OriginalPath() string
func (*OriRequest) Path ¶
func (this *OriRequest) Path() string
func (*OriRequest) Query ¶
func (this *OriRequest) Query() map[string]string
func (*OriRequest) R ¶
func (this *OriRequest) R() *http.Request
func (*OriRequest) Referer ¶
func (this *OriRequest) Referer() string
type OriResponse ¶
type OriResponse struct {
// contains filtered or unexported fields
}
func (*OriResponse) F ¶
func (this *OriResponse) F() map[string]Tout
func (*OriResponse) Get ¶
func (this *OriResponse) Get(key string) string
func (*OriResponse) JSON ¶
func (this *OriResponse) JSON(obj interface{}) error
func (*OriResponse) JSONEx ¶
func (this *OriResponse) JSONEx(obj interface{}, code int) error
func (*OriResponse) R ¶
func (this *OriResponse) R() http.ResponseWriter
func (*OriResponse) Redirect ¶
func (this *OriResponse) Redirect(newAddr string) error
func (*OriResponse) RedirectEX ¶
func (this *OriResponse) RedirectEX(newAddr string, code int) error
func (*OriResponse) Send ¶
func (this *OriResponse) Send(content string) error
func (*OriResponse) SendCode ¶
func (this *OriResponse) SendCode(code int) error
func (*OriResponse) SendFile ¶
func (this *OriResponse) SendFile(filepath string) error
func (*OriResponse) SendFileEx ¶
type Request ¶
type Request interface { // Path is the url not containing mount point. Path() string // BaseUrl is the mount point BaseUrl() string // OriginalPath is the full URL requested. OriginalPath() string // the Hostname of the request Hostname() string // the query of requst // the original query processor is map[string][]string, this one just // reserve the first setting. Query() map[string]string // Preserved for midware. By default it will not return a ReadCloser for // raw read. Body() Tout // the method of the request Method() string // get data in the headers, if not specified, return "" Get(string) string GetAll(key string) []string // get the Original resonse, only use it for advanced purpose R() *http.Request // extra use for midwares. Most of time the value is a function. F() map[string]Tout // nonexist returns "" Referer() string // contains filtered or unexported methods }
type Response ¶
type Response interface { // Quick send with code 200. While done, any other operation except Write is not allowed anymore. // However, due to the framework of net/http, the response will not be closed until // the function returns. So it is suggested to return immediately. Send(string) error // Set headers. Set(string, string) error // Get the value in the headers. If nothing, returns "". Get(string) string // Write data to response body. It allows any corresponding operation. Write([]byte) (int, error) // Send files without any extra headers except contenttype and encrypt. // if contenttype is "", it will be inferred from file extension. // if encoder is nil, no encoder is used SendFileEx(string, string, encoding.Encoder, int) error // Shorthand for SendFileEx, infer mime, using gzip and return 200. SendFile(string) error // While done, any other operation except Write is not allowed anymore. Status(string, int) error // While done, any other operation except Write is not allowed anymore. SendCode(int) error // While done, any other operation except Write is not allowed anymore. Redirect(string) error RedirectEX(string, int) error // While done, any other operation except Write is not allowed anymore. JSON(interface{}) error JSONEx(interface{}, int) error // get the Original resonse, only use it for advanced purpose R() http.ResponseWriter // extra use for midwares. Most of time the value is a function. F() map[string]Tout }
Depended by: gurgling/midwares/analyzer
func NewResponse ¶
func NewResponse(w http.ResponseWriter) Response
type Router ¶
type Router interface { Use(paraList ...interface{}) Router Get(paraList ...interface{}) Router Post(paraList ...interface{}) Router Put(paraList ...interface{}) Router Delete(paraList ...interface{}) Router SetErrorHandler(RouterErrorCatcher) Router Set404Handler(Terminal) Router Last(Cattail) Router UseSpecified(string, string, Tout, bool) Router ServeHTTP(http.ResponseWriter, *http.Request) Handler(Request, Response) (bool, Request, Response) Launch(paraList ...interface{}) error F() map[string]Tout }
Indeed an interface.
func ARegexpRouter ¶
func ARegexpRouter() Router
type RouterErrorCatcher ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.