Documentation
¶
Index ¶
- Constants
- func Add(controllers ...interface{})
- func InitJwt(wd string) error
- type Application
- type ApplicationContext
- type ApplicationInterface
- type Context
- func (ctx *Context) Do(handlers context.Handlers)
- func (ctx *Context) HTML(htmlContents string) (int, error)
- func (ctx *Context) Next()
- func (ctx *Context) RequestBody(data interface{}) error
- func (ctx *Context) RequestEx(data interface{}, cb func() error) error
- func (ctx *Context) RequestForm(data interface{}) error
- func (ctx *Context) RequestParams(data interface{}) error
- func (ctx *Context) ResponseBody(message string, data interface{})
- func (ctx *Context) ResponseError(message string, code int)
- func (ctx *Context) ResponseString(data string)
- type Controller
- type ExtendedContext
- type Health
- type JwtController
- type JwtMap
- type JwtMiddleware
- type TestApplication
- func (ta *TestApplication) Delete(path string, pathargs ...interface{}) *httpexpect.Request
- func (ta *TestApplication) Get(path string, pathargs ...interface{}) *httpexpect.Request
- func (ta *TestApplication) Patch(path string, pathargs ...interface{}) *httpexpect.Request
- func (ta *TestApplication) Post(path string, pathargs ...interface{}) *httpexpect.Request
- func (ta *TestApplication) Put(path string, pathargs ...interface{}) *httpexpect.Request
- func (ta *TestApplication) Request(method, path string, pathargs ...interface{}) *httpexpect.Request
- func (ta *TestApplication) RunTestServer(t *testing.T) *httpexpect.Expect
- type TestApplicationInterface
- type Token
Constants ¶
const ( AuthType = "AuthType" AuthTypeDefault = "" AuthTypeAnon = "anon" AuthTypeJwt = "jwt" BeforeMethod = "Before" AfterMethod = "After" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
Application is the struct of web Application TODO: application should be singleton and private
func NewApplication ¶
func NewApplication(controllers ...interface{}) *Application
NewApplication create new web application instance and init it
func (*Application) Config ¶
func (wa *Application) Config() *starter.SystemConfiguration
Config returns application config
func (*Application) Init ¶
func (wa *Application) Init(controllers ...interface{}) error
Init init web application
type ApplicationContext ¶ added in v0.2.0
type ApplicationContext interface {
context.Context
ExtendedContext
}
type ApplicationInterface ¶
type ApplicationInterface interface {
Init()
Config() *starter.SystemConfiguration
Run()
}
ApplicationInterface is the interface of web application
type Context ¶
type Context struct {
// Optional Part 1: embed (optional but required if you don't want to override all context's methods)
// it's the context/context.go#context struct but you don't need to know it.
context.Context
ExtendedContext
}
Context Create your own custom Context, put any fields you wanna need.
func (*Context) Do ¶
Do: The only one important if you will override the Context with an embedded context.Context inside it. Required in order to run the handlers via this "*Context".
func (*Context) Next ¶
func (ctx *Context) Next()
Next: The second one important if you will override the Context with an embedded context.Context inside it. Required in order to run the chain of handlers via this "*Context".
func (*Context) RequestBody ¶
RequestBody get RequestBody
func (*Context) RequestForm ¶ added in v0.2.0
RequestForm get RequestFrom
func (*Context) RequestParams ¶ added in v0.2.0
RequestParams get RequestParams
func (*Context) ResponseBody ¶
ResponseBody set response
func (*Context) ResponseError ¶
Response Errorset response
func (*Context) ResponseString ¶ added in v0.2.0
ResponseBody set response
type Controller ¶
Controller is the web base controller
func (*Controller) AuthType ¶
func (c *Controller) AuthType() string
type ExtendedContext ¶ added in v0.2.0
type Health ¶
type Health struct {
Status string `json:"status"`
}
Health is the health check struct
type JwtController ¶ added in v0.2.0
type JwtController struct {
Controller
}
JwtController is the base web controller that enabled JWT
func (*JwtController) AuthType ¶ added in v0.2.0
func (c *JwtController) AuthType() string
func (*JwtController) ParseToken ¶ added in v0.2.0
func (c *JwtController) ParseToken(claims jwt.MapClaims, prop string) string
ParseToken is an util that parsing JWT token from jwt.MapClaims
type JwtMiddleware ¶
type JwtMiddleware struct {
mwjwt.Middleware
}
JwtMiddleware derrived from github.com/iris-contrib/middleware/jwt/Middleware
func NewJwtMiddleware ¶ added in v0.2.0
func NewJwtMiddleware(cfg ...mwjwt.Config) *JwtMiddleware
NewJwtMiddleware New constructs a new Secure instance with supplied options.
func (*JwtMiddleware) CheckJWT ¶
func (m *JwtMiddleware) CheckJWT(ctx context.Context) error
CheckJWT the main functionality, checks for token
func (*JwtMiddleware) Serve ¶
func (m *JwtMiddleware) Serve(ctx context.Context)
Serve the middleware's action
type TestApplication ¶ added in v0.2.0
type TestApplication struct {
Application
// contains filtered or unexported fields
}
TestApplication the test web application for unit test only
func NewTestApplication ¶ added in v0.2.0
func NewTestApplication(t *testing.T, controllers ...interface{}) *TestApplication
NewTestApplication returns the new test application
func (*TestApplication) Delete ¶ added in v0.2.0
func (ta *TestApplication) Delete(path string, pathargs ...interface{}) *httpexpect.Request
Delete wrap of Request with Delete method
func (*TestApplication) Get ¶ added in v0.2.0
func (ta *TestApplication) Get(path string, pathargs ...interface{}) *httpexpect.Request
Get wrap of Request with Get method
func (*TestApplication) Patch ¶ added in v0.2.0
func (ta *TestApplication) Patch(path string, pathargs ...interface{}) *httpexpect.Request
Patch wrap of Request with Patch method
func (*TestApplication) Post ¶ added in v0.2.0
func (ta *TestApplication) Post(path string, pathargs ...interface{}) *httpexpect.Request
Post wrap of Request with POST method
func (*TestApplication) Put ¶ added in v0.2.0
func (ta *TestApplication) Put(path string, pathargs ...interface{}) *httpexpect.Request
Put wrap of Request with Put method
func (*TestApplication) Request ¶ added in v0.2.0
func (ta *TestApplication) Request(method, path string, pathargs ...interface{}) *httpexpect.Request
Request request for unit test
func (*TestApplication) RunTestServer ¶ added in v0.2.0
func (ta *TestApplication) RunTestServer(t *testing.T) *httpexpect.Expect
RunTestServer run the test server
type TestApplicationInterface ¶ added in v0.2.0
type TestApplicationInterface interface {
ApplicationInterface
NewTestServer(t *testing.T) *httpexpect.Expect
}
TestApplicationInterface the test web application interface for unit test only