mvc

package
v1.7.3 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMvcTemplate = "v1/{controller}/{action}"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionDescriptor

type ActionDescriptor struct {
	ActionName   string
	ActionMethod string
	MethodInfo   reflectx.MethodInfo
}

type ActionExecutorContext

type ActionExecutorContext struct {
	ControllerName   string
	ActionName       string
	Controller       IController
	ActionDescriptor ActionDescriptor
	Context          *context.HttpContext
}

type ActionFilterChain

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

ActionFilter Chain

func NewActionFilterChain

func NewActionFilterChain(pattern string, filter IActionFilter) ActionFilterChain

New ActionFilter Chain

func (ActionFilterChain) GetFilter

func (chain ActionFilterChain) GetFilter() IActionFilter

Get ActionFilter of Chain

func (ActionFilterChain) MatchFilter

func (chain ActionFilterChain) MatchFilter(want string) IActionFilter

// Match path for pattern to ActionFilter

func (ActionFilterChain) MatchPath

func (chain ActionFilterChain) MatchPath(want string) bool

Match path for pattern

func (ActionFilterChain) SetFilter

func (chain ActionFilterChain) SetFilter(filter IActionFilter)

Set ActionFilter to Chain

type ActionFilterContext

type ActionFilterContext struct {
	ActionExecutorContext
	Result interface{}
}

ActionFilter context

type ActionMethodExecutor

type ActionMethodExecutor struct {
}

func NewActionMethodExecutor

func NewActionMethodExecutor() ActionMethodExecutor

func (ActionMethodExecutor) Execute

func (actionExecutor ActionMethodExecutor) Execute(ctx *ActionExecutorContext) interface{}

type ApiController

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

func (*ApiController) Fail

func (c *ApiController) Fail(msg string) ApiResult

func (*ApiController) GetName

func (c *ApiController) GetName() string

func (*ApiController) OK

func (c *ApiController) OK(data interface{}) ApiResult

func (*ApiController) SetViewEngine

func (c *ApiController) SetViewEngine(viewEngine view.IViewEngine)

func (*ApiController) View

func (c *ApiController) View(name string, data interface{}) actionresult.IActionResult

type ApiResult

type ApiResult struct {
	Success bool
	Message string
	Data    interface{}
}

type ControllerBuilder

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

ControllerBuilder: controller builder

func NewControllerBuilder

func NewControllerBuilder() *ControllerBuilder

NewControllerBuilder new controller builder

func (*ControllerBuilder) AddController

func (builder *ControllerBuilder) AddController(controllerCtor interface{})

AddController add controller (ctor) to ioc.

func (*ControllerBuilder) AddFilter

func (builder *ControllerBuilder) AddFilter(pattern string, actionFilter IActionFilter)

add filter to mvc

func (*ControllerBuilder) AddViews

func (builder *ControllerBuilder) AddViews(option *view.Option)

AddViews add views to mvc

func (*ControllerBuilder) AddViewsByConfig

func (builder *ControllerBuilder) AddViewsByConfig()

AddViewsByConfig add views by config

func (*ControllerBuilder) GetControllerDescriptorByName

func (builder *ControllerBuilder) GetControllerDescriptorByName(name string) ControllerDescriptor

GetControllerDescriptorByName get controller descriptor by controller name

func (*ControllerBuilder) GetControllerDescriptorList

func (builder *ControllerBuilder) GetControllerDescriptorList() []ControllerDescriptor

GetControllerDescriptorList is get controller descriptor array

func (*ControllerBuilder) GetMvcOptions

func (builder *ControllerBuilder) GetMvcOptions() *Options

GetMvcOptions get mvc options

func (*ControllerBuilder) GetRouterHandler

func (builder *ControllerBuilder) GetRouterHandler() *RouterHandler

GetRouterHandler is get mvc router handler.

func (*ControllerBuilder) SetConfiguration

func (builder *ControllerBuilder) SetConfiguration(configuration abstractions.IConfiguration)

SetConfiguration set configuration

func (*ControllerBuilder) SetViewEngine

func (builder *ControllerBuilder) SetViewEngine(viewEngine view.IViewEngine)

SetViewEngine set view engine

func (*ControllerBuilder) SetupOptions

func (builder *ControllerBuilder) SetupOptions(configOption func(options *Options))

SetupOptions , setup mvc builder options

type ControllerDescriptor

type ControllerDescriptor struct {
	ControllerName string
	ControllerType interface{} // ctor func of controller
	// contains filtered or unexported fields
}

ControllerDescriptor

func NewControllerDescriptor

func NewControllerDescriptor(name string, controllerType reflect.Type, controllerCtor interface{}) ControllerDescriptor

NewControllerDescriptor create new controller descriptor

func (ControllerDescriptor) GetActionDescriptorByName

func (controllerDescriptor ControllerDescriptor) GetActionDescriptorByName(actionName string) (ActionDescriptor, bool)

GetActionDescriptorByName get action descriptor by name

func (ControllerDescriptor) GetActionDescriptors

func (controllerDescriptor ControllerDescriptor) GetActionDescriptors() []ActionDescriptor

GetActionDescriptors get action descriptor list

type IActionFilter

type IActionFilter interface {
	OnActionExecuting(context ActionFilterContext) bool
	OnActionExecuted(context ActionFilterContext)
}

type IController

type IController interface {
	GetName() string
	SetViewEngine(viewEngine view.IViewEngine)
}

func ActivateController

func ActivateController(serviceProvider dependencyinjection.IServiceProvider, controllerName string) (IController, error)

type Options

type Options struct {
	Template   *RouteTemplate
	ViewOption *view.Option
}

func NewMvcOptions

func NewMvcOptions() *Options

NewMvcOptions new mvc options.

func (*Options) MapRoute

func (options *Options) MapRoute(template string)

MapRoute map url route to mvc url template.

type RequestBody

type RequestBody struct {
}

type RouteTemplate

type RouteTemplate struct {
	Template       string
	TemplateSplits []string
	ControllerName string
	ActionName     string
	// contains filtered or unexported fields
}

func NewRouteTemplate

func NewRouteTemplate(temp string) *RouteTemplate

func (*RouteTemplate) GetActionIndex

func (template *RouteTemplate) GetActionIndex() int

func (*RouteTemplate) GetControllerIndex

func (template *RouteTemplate) GetControllerIndex() int

func (*RouteTemplate) Match

func (template *RouteTemplate) Match(pathComponents []string) bool

type RouterHandler

type RouterHandler struct {
	ControllerFilters     []ActionFilterChain
	ControllerDescriptors map[string]ControllerDescriptor
	Options               *Options
	ViewEngine            view.IViewEngine
}

func NewMvcRouterHandler

func NewMvcRouterHandler() *RouterHandler

func (*RouterHandler) Invoke

func (handler *RouterHandler) Invoke(ctx *context.HttpContext, pathComponents []string) func(ctx *context.HttpContext)

func (RouterHandler) MatchFilters

func (handler RouterHandler) MatchFilters(ctx *context.HttpContext) []IActionFilter

type RouterHandlerResponse

type RouterHandlerResponse struct {
	Result interface{}
}

func (*RouterHandlerResponse) Callback

func (response *RouterHandlerResponse) Callback(ctx *context.HttpContext)

Jump to

Keyboard shortcuts

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