Documentation ¶
Index ¶
- Variables
- func HandleRestful(pattern string, fn func() IController)
- func InitDb(dbPath string) error
- func Log(lv LogLevel, e interface{})
- func ResetController(c IController, w http.ResponseWriter, r *http.Request)
- func Run(cfg Config)
- type ApiStatusError
- type Config
- type Controller
- func (this *Controller) Delete() error
- func (this *Controller) Get() error
- func (this *Controller) JsonRender(status int, message string, data interface{}) error
- func (this *Controller) JsonSuccess(data interface{}) error
- func (this *Controller) MethodNotAllowed() error
- func (this *Controller) ParseJsonBody(data interface{}) (err error)
- func (this *Controller) Post() error
- func (this *Controller) Put() error
- func (this *Controller) QueryGet(key string) string
- func (this *Controller) Reset(w http.ResponseWriter, r *http.Request)
- type IController
- type LogLevel
- type Model
- type StatusError
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrBadRequest = NewStatusError(http.StatusBadRequest, "bad request") ErrNotFound = NewStatusError(http.StatusNotFound, "not found") ErrMethodNotAllowed = NewStatusError(http.StatusMethodNotAllowed, "method not allowed") ErrInternalServerError = NewStatusError(http.StatusInternalServerError, "internal server error") ErrBucketNotFound = errors.New("Bucket not found") )
definded error
View Source
var Db *dbHelper
Db is a single instance of dbHelper
Functions ¶
func HandleRestful ¶
func HandleRestful(pattern string, fn func() IController)
func ResetController ¶
func ResetController(c IController, w http.ResponseWriter, r *http.Request)
Types ¶
type ApiStatusError ¶
type ApiStatusError struct {
*StatusError
}
func NewApiStatusError ¶
func NewApiStatusError(status int, message string) *ApiStatusError
type Config ¶
type Config struct { // User defined Port string DbPath string // App need Routers map[string]func() IController }
Config is a struct named Config
type Controller ¶
type Controller struct { W http.ResponseWriter R *http.Request // contains filtered or unexported fields }
Controller is a struct named Controller
func (*Controller) Delete ¶
func (this *Controller) Delete() error
func (*Controller) Get ¶
func (this *Controller) Get() error
func (*Controller) JsonRender ¶
func (this *Controller) JsonRender(status int, message string, data interface{}) error
func (*Controller) JsonSuccess ¶
func (this *Controller) JsonSuccess(data interface{}) error
func (*Controller) MethodNotAllowed ¶
func (this *Controller) MethodNotAllowed() error
func (*Controller) ParseJsonBody ¶
func (this *Controller) ParseJsonBody(data interface{}) (err error)
func (*Controller) Post ¶
func (this *Controller) Post() error
func (*Controller) Put ¶
func (this *Controller) Put() error
func (*Controller) QueryGet ¶
func (this *Controller) QueryGet(key string) string
func (*Controller) Reset ¶
func (this *Controller) Reset(w http.ResponseWriter, r *http.Request)
Reset reset controller for handle one request
type IController ¶
type IController interface { // reset rw of one context Reset(http.ResponseWriter, *http.Request) // RESTful Get() error Post() error Put() error Delete() error }
IController is a interface named IController
type StatusError ¶
type StatusError struct {
// contains filtered or unexported fields
}
func NewStatusError ¶
func NewStatusError(status int, message string) *StatusError
func (*StatusError) Error ¶
func (this *StatusError) Error() string
func (*StatusError) NewMessage ¶
func (this *StatusError) NewMessage(message interface{}) *StatusError
func (*StatusError) NewMessageSpf ¶
func (this *StatusError) NewMessageSpf(args ...interface{}) *StatusError
Click to show internal directories.
Click to hide internal directories.