func (input *BeegoInput) Cookie(key string) string {
	ck, err := input.Request.Cookie(key)
	if err != nil {
		return ""
	}
	return ck.Value
}
Cookie returns request cookie item string by a given key.
if non-existed, return empty string.
package context
import (
	"bytes"
	"errors"
	"io/ioutil"
	"net/http"
	"net/url"
	"reflect"
	"strconv"
	"strings"
	"github.com/astaxie/beego/session"
)
type BeegoInput struct {
	CruSession    session.SessionStore
	Params        map[string]string
	Data          map[interface{}]interface{}  
	Request       *http.Request
	RequestBody   []byte
	RunController reflect.Type
	RunMethod     string
}
func NewInput(req *http.Request) *BeegoInput {
	return &BeegoInput{
		Params:  make(map[string]string),
		Data:    make(map[interface{}]interface{}),
		Request: req,
	}
}
func (input *BeegoInput) Protocol() string {
	return input.Request.Proto
}
func (input *BeegoInput) Uri() string {
	return input.Request.RequestURI
}
func (input *BeegoInput) Url() string {
	return input.Request.URL.Path
}
func (input *BeegoInput) Site() string {
	return input.Scheme() + "://" + input.Domain()
}
func (input *BeegoInput) Scheme() string {
	if input.Request.URL.Scheme != "" {
		return input.Request.URL.Scheme
	} else if input.Request.TLS == nil {
		return "http"
	} else {
		return "https"
	}
}
func (input *BeegoInput) Domain() string {
	return input.Host()
}
func (input *BeegoInput) Host() string {
	if input.Request.Host != "" {
		hostParts := strings.Split(input.Request.Host, ":")
		if len(hostParts) > 0 {
			return hostParts[0]
		}
		return input.Request.Host
	}
	return "localhost"
}
func (input *BeegoInput) Method() string {
	return input.Request.Method
}
func (input *BeegoInput) Is(method string) bool {
	return input.Method() == method
}
func (input *BeegoInput) IsGet() bool {
	return input.Is("GET")
}
func (input *BeegoInput) IsPost() bool {
	return input.Is("POST")
}
func (input *BeegoInput) IsHead() bool {
	return input.Is("HEAD")
}
func (input *BeegoInput) IsOptions() bool {
	return input.Is("OPTIONS")
}
func (input *BeegoInput) IsPut() bool {
	return input.Is("PUT")
}
func (input *BeegoInput) IsDelete() bool {
	return input.Is("DELETE")
}
func (input *BeegoInput) IsPatch() bool {
	return input.Is("PATCH")
}
func (input *BeegoInput) IsAjax() bool {
	return input.Header("X-Requested-With") == "XMLHttpRequest"
}
func (input *BeegoInput) IsSecure() bool {
	return input.Scheme() == "https"
}
func (input *BeegoInput) IsWebsocket() bool {
	return input.Header("Upgrade") == "websocket"
}
func (input *BeegoInput) IsUpload() bool {
	return strings.Contains(input.Header("Content-Type"), "multipart/form-data")
}
func (input *BeegoInput) IP() string {
	ips := input.Proxy()
	if len(ips) > 0 && ips[0] != "" {
		rip := strings.Split(ips[0], ":")
		return rip[0]
	}
	ip := strings.Split(input.Request.RemoteAddr, ":")
	if len(ip) > 0 {
		if ip[0] != "[" {
			return ip[0]
		}
	}
	return "127.0.0.1"
}
func (input *BeegoInput) Proxy() []string {
	if ips := input.Header("X-Forwarded-For"); ips != "" {
		return strings.Split(ips, ",")
	}
	return []string{}
}
func (input *BeegoInput) Refer() string {
	return input.Header("Referer")
}
func (input *BeegoInput) SubDomains() string {
	parts := strings.Split(input.Host(), ".")
	return strings.Join(parts[len(parts)-2:], ".")
}
func (input *BeegoInput) Port() int {
	parts := strings.Split(input.Request.Host, ":")
	if len(parts) == 2 {
		port, _ := strconv.Atoi(parts[1])
		return port
	}
	return 80
}
func (input *BeegoInput) UserAgent() string {
	return input.Header("User-Agent")
}
func (input *BeegoInput) Param(key string) string {
	if v, ok := input.Params[key]; ok {
		return v
	}
	return ""
}
func (input *BeegoInput) Query(key string) string {
	if val := input.Param(key); val != "" {
		return val
	}
	if input.Request.Form == nil {
		input.Request.ParseForm()
	}
	return input.Request.Form.Get(key)
}
func (input *BeegoInput) Header(key string) string {
	return input.Request.Header.Get(key)
}