Documentation
¶
Index ¶
Constants ¶
View Source
const VERSION = "1.2.0"
Variables ¶
View Source
var Conf configInterface
Conf : user can get config items
View Source
var Log logger
Log : use Log to write logs
Functions ¶
func JSONToString ¶
func JSONToString(data interface{}) string
Types ¶
type Context ¶
type Context interface { //resp body WriteBytes(b []byte) WriteString(str string) DataHTML(data interface{}, filenames ...string) JSONHTML(data interface{}, filenames ...string) Redirect(path string) Code(statusCode int) PathParam(key string) string FormFile(fileName string) (multipart.File, *multipart.FileHeader, error) //session&Cookie GetSession() Session DeleteSession() RefreshSession() SetCookie(key, value, path string) //form FormValue(key string) string BindForm(obj interface{}) map[string]error BindJSON(obj interface{}) error BindMap() (map[string]interface{}, error) //resp Text(code int) JSON(code int, b []byte) error JSONOk() error JSONFrom(code int, data interface{}) error JSONString(code int, data string) error JSONMsg(code int, key string, data interface{}) error HTML(filenames ...string) File(filename string) Attachment(filename string) PutData(key string, data interface{}) //web context R() *http.Request W() http.ResponseWriter Method() string Body() ([]byte, error) //switch method OnMethod(method string, f func(Context)) Context OnPOST(f func(Context)) Context OnGET(f func(Context)) Context OnDELETE(f func(Context)) Context OnPUT(f func(Context)) Context }
type Properties ¶
func NewProperties ¶
func NewProperties(logFile string, sessionMaxLifeTime int) *Properties
type Server ¶
type Server interface { //base RunAt(port string) error Run() error GetPort() string GetMux() *http.ServeMux //method Get(path string, handler func(ctx Context)) Server Post(path string, handler func(ctx Context)) Server Put(path string, handler func(ctx Context)) Server Delete(path string, handler func(ctx Context)) Server Head(path string, handler func(ctx Context)) Server //static folder Static(folder string) Server //favicon ico Favicon(filePath string) Server //common handler Handler(path string, handler func(ctx Context), method string) Server AllHandler(path string, handler func(ctx Context)) Server HandleFunc(path string, handler func(w http.ResponseWriter, r *http.Request)) Server //set filter AddFilter(handler func(ctx Context) bool) Server AddAnnoURL(url string, methods ...string) Server //error handler HTTPErrorHandler(status int, handler func(ctx Context)) Server }
Server : web server interface
type Session ¶
type Session interface { Set(key, value interface{}) //set session value Get(key interface{}) interface{} //get session value Delete(key interface{}) //delete session value ID() string //back current sessionID LeftTime() int64 //get this session's timeout // contains filtered or unexported methods }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.