web

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2018 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BeforeMethod = "Before"
	AfterMethod  = "After"
)

Variables

View Source
var (
	ControllersNotFoundError = errors.New("[app] controllers not found")
	InvalidControllerError   = errors.New("[app] invalid controller")
)

Functions

func DefaultConfiguration

func DefaultConfiguration() iris.Configuration

DefaultConfiguration returns the default configuration for an iris station, fills the main Configuration

func NewApplication

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

NewApplication create new web application instance and init it

func RegisterInitializer

func RegisterInitializer(initializer ...interface{})

func RestController

func RestController(controllers ...interface{})

Add add controller to controllers container

Types

type AnonController

type AnonController interface{}

type ApplicationContext

type ApplicationContext interface {
	context.Context
	ExtendedContext
}

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

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

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

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

HTML Override any context's method you want... [...]

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

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

RequestBody get RequestBody

func (*Context) RequestEx

func (ctx *Context) RequestEx(data interface{}, cb func() error) error

RequestEx get RequestBody

func (*Context) RequestForm

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

RequestForm get RequestFrom

func (*Context) RequestParams

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

RequestParams get RequestParams

func (*Context) ResponseBody

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

ResponseBody set response

func (*Context) ResponseError

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

Response Errorset response

func (*Context) ResponseString

func (ctx *Context) ResponseString(data string)

ResponseBody set response

func (*Context) Translate

func (ctx *Context) Translate(format string, args ...interface{}) string

Translate override base context method Translate to return format if i18n is not enabled

type Controller

type Controller struct {
	AnonController
	ContextMapping string
	Ctx            *Context
}

Controller is the web base controller

type ExtendedContext

type ExtendedContext interface {
	RequestEx(data interface{}, cb func() error) error
	RequestBody(data interface{}) error
	RequestForm(data interface{}) error
	ResponseBody(message string, data interface{})
	ResponseError(message string, code int)
}

type TestApplication

type TestApplication interface {
	app.Application
	RunTestServer(t *testing.T) *httpexpect.Expect
	Request(method, path string, pathargs ...interface{}) *httpexpect.Request
	Post(path string, pathargs ...interface{}) *httpexpect.Request
	Get(path string, pathargs ...interface{}) *httpexpect.Request
	Put(path string, pathargs ...interface{}) *httpexpect.Request
	Delete(path string, pathargs ...interface{}) *httpexpect.Request
	Patch(path string, pathargs ...interface{}) *httpexpect.Request
}

TestApplicationInterface the test web application interface for unit test only

func NewTestApplication

func NewTestApplication(t *testing.T, controllers ...interface{}) TestApplication

NewTestApplication returns the new test application

Jump to

Keyboard shortcuts

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