web

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2018 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthTypeDefault = ""
	AuthTypeAnon    = "anon"
	AuthTypeJwt     = "jwt"
)

Variables

View Source
var (
	Controllers []interface{}
)

Functions

func Add

func Add(controller interface{})

func GetSignKey

func GetSignKey() *rsa.PrivateKey

func InitJwt

func InitJwt(wd string) error

func NewTestServer

func NewTestServer(t *testing.T, controllers ...interface{}) (*httpexpect.Expect, error)

Types

type Application

type Application struct {
	// contains filtered or unexported fields
}

func NewApplication

func NewApplication(controllers ...interface{}) *Application

func (*Application) Config

func (wa *Application) Config() *system.Configuration

func (*Application) Init

func (wa *Application) Init(controllers []interface{}) error

func (*Application) Run

func (wa *Application) Run()

func (*Application) RunTestServer

func (wa *Application) RunTestServer(t *testing.T) *httpexpect.Expect

type ApplicationInterface

type ApplicationInterface interface {
	Init()
	Config() *system.Configuration
	GetSignKey() *rsa.PrivateKey
	Run()
	NewTestServer(t *testing.T) *httpexpect.Expect
}

type Context

type Context struct {
	// Optional Part 1: embed (optional but required if you don't want to override all context's methods)
	context.Context // it's the context/context.go#context struct but you don't need to know it.
	ContextInterface
}

Create your own custom Context, put any fields you wanna need.

func (*Context) Do

func (ctx *Context) Do(handlers context.Handlers)

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) HTML

func (ctx *Context) HTML(htmlContents string) (int, error)

func (*Context) Next

func (ctx *Context) 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

func (ctx *Context) RequestBody(data interface{}) error

get response

func (*Context) ResponseBody

func (ctx *Context) ResponseBody(message string, data interface{})

set response

func (*Context) ResponseError

func (ctx *Context) ResponseError(message string, code int)

set response

type ContextInterface

type ContextInterface interface {
	RequestBody(data interface{}) error
	Response(message string, data interface{})
	ResponseError(message string, code int)
}

type Controller

type Controller struct {
	ContextMapping string
	AuthType       string
}

type Health

type Health struct {
	Status string `json:"status"`
}

type JwtMap

type JwtMap map[string]interface{}

type JwtMiddleware

type JwtMiddleware struct {
	jwtmiddleware.Middleware
}

func GetJwtHandler

func GetJwtHandler() *JwtMiddleware

func NewJwtMiddlware

func NewJwtMiddlware(cfg ...jwtmiddleware.Config) *JwtMiddleware

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 Token

type Token string

func GenerateJwtToken

func GenerateJwtToken(payload JwtMap, expired int64, unit time.Duration) (*Token, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL