Documentation ¶
Index ¶
- Constants
- Variables
- func EmptyHandler(ctx *context.HttpContext)
- type ActionDescriptor
- type ActionExecutorContext
- type ActionFilterChain
- type ActionFilterContext
- type ActionMethodExecutor
- type ActionParametersMappingFunc
- type ApiController
- func (c *ApiController) ApiResult() *ApiResultBuilder
- func (c *ApiController) Fail(msg string) ApiResult
- func (c *ApiController) GetName() string
- func (c *ApiController) OK(data interface{}) ApiResult
- func (c *ApiController) SetViewEngine(viewEngine view.IViewEngine)
- func (c *ApiController) View(name string, data interface{}) actionresult.IActionResult
- type ApiDocResult
- type ApiDocResultBuilder
- func (arb *ApiDocResultBuilder[T]) Build() ApiDocResult[T]
- func (arb *ApiDocResultBuilder[T]) Data(data T) *ApiDocResultBuilder[T]
- func (arb *ApiDocResultBuilder[T]) Fail() *ApiDocResultBuilder[T]
- func (arb *ApiDocResultBuilder[T]) Message(msg string) *ApiDocResultBuilder[T]
- func (arb *ApiDocResultBuilder[T]) MessageWithFunc(fc func() string) *ApiDocResultBuilder[T]
- func (arb *ApiDocResultBuilder[T]) StatusCode(statusCode int) *ApiDocResultBuilder[T]
- func (arb *ApiDocResultBuilder[T]) Success() *ApiDocResultBuilder[T]
- type ApiResult
- func Fail(data interface{}) ApiResult
- func FailVoid() ApiResult
- func FailWithMsg(data interface{}, msg string) ApiResult
- func FailWithMsgFunc(data interface{}, fc func() string) ApiResult
- func Success(data interface{}) ApiResult
- func SuccessVoid() ApiResult
- func SuccessWithMsg(data interface{}, msg string) ApiResult
- func SuccessWithMsgFunc(data interface{}, fc func() string) ApiResult
- type ApiResultBuilder
- func (arb *ApiResultBuilder) Build() ApiResult
- func (arb *ApiResultBuilder) Data(data interface{}) *ApiResultBuilder
- func (arb *ApiResultBuilder) Fail() *ApiResultBuilder
- func (arb *ApiResultBuilder) Message(msg string) *ApiResultBuilder
- func (arb *ApiResultBuilder) MessageWithFunc(fc func() string) *ApiResultBuilder
- func (arb *ApiResultBuilder) StatusCode(statusCode int) *ApiResultBuilder
- func (arb *ApiResultBuilder) Success() *ApiResultBuilder
- type ControllerBuilder
- func (builder *ControllerBuilder) AddController(controllerCtor interface{})
- func (builder *ControllerBuilder) AddFilter(pattern string, actionFilter IActionFilter)
- func (builder *ControllerBuilder) AddViews(option *view.Option)
- func (builder *ControllerBuilder) AddViewsByConfig()
- func (builder *ControllerBuilder) EnableRouteAttributes()
- func (builder *ControllerBuilder) GetControllerDescriptorByName(name string) ControllerDescriptor
- func (builder *ControllerBuilder) GetControllerDescriptorList() []ControllerDescriptor
- func (builder *ControllerBuilder) GetMvcOptions() *Options
- func (builder *ControllerBuilder) GetRouterHandler() *RouterHandler
- func (builder *ControllerBuilder) SetConfiguration(configuration abstractions.IConfiguration)
- func (builder *ControllerBuilder) SetRouteProcessor(processor IRouterAttributeBuilder)
- func (builder *ControllerBuilder) SetViewEngine(viewEngine view.IViewEngine)
- func (builder *ControllerBuilder) SetupOptions(configOption func(options *Options))
- type ControllerDescriptor
- type IActionFilter
- type IController
- type IRouterAttributeBuilder
- type MatchMvcInfo
- type Options
- type RequestBody
- type RequestDelete
- type RequestGET
- type RequestHead
- type RequestOptions
- type RequestPOST
- type RequestPatch
- type RequestPut
- type RouteAttribute
- type RouteAttributeCollection
- func (collection *RouteAttributeCollection) Add(routeAttribute RouteAttribute)
- func (collection *RouteAttributeCollection) Disable()
- func (collection *RouteAttributeCollection) Enable()
- func (collection *RouteAttributeCollection) HasElement() bool
- func (collection *RouteAttributeCollection) IsEnable() bool
- func (collection *RouteAttributeCollection) Match(ctx *context.HttpContext, pathComponents []string, match *MatchMvcInfo) bool
- func (collection *RouteAttributeCollection) SetProcessor(processor IRouterAttributeBuilder)
- type RouteTemplate
- type RouterHandler
- type RouterHandlerResponse
- type StatusCoder
Constants ¶
const (
DefaultMvcTemplate = "v1/{controller}/{action}"
)
Variables ¶
var RequestMppingFuncs map[string]ActionParametersMappingFunc = map[string]ActionParametersMappingFunc{
"HttpContext": httpContextMappingMapping,
"Default": requestBodyMappingMapping,
}
Functions ¶
func EmptyHandler ¶
func EmptyHandler(ctx *context.HttpContext)
Types ¶
type ActionDescriptor ¶
type ActionDescriptor struct { ActionName string ActionMethod string MethodInfo reflectx.MethodInfo IsAttributeRoute bool Route *RouteAttribute }
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 {
// contains filtered or unexported fields
}
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) ApiResult ¶
func (c *ApiController) ApiResult() *ApiResultBuilder
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 ApiDocResult ¶
type ApiDocResultBuilder ¶
type ApiDocResultBuilder[T any] struct { // contains filtered or unexported fields }
func ApiDocumentResult ¶
func ApiDocumentResult[T any]() *ApiDocResultBuilder[T]
func (*ApiDocResultBuilder[T]) Build ¶
func (arb *ApiDocResultBuilder[T]) Build() ApiDocResult[T]
func (*ApiDocResultBuilder[T]) Data ¶
func (arb *ApiDocResultBuilder[T]) Data(data T) *ApiDocResultBuilder[T]
func (*ApiDocResultBuilder[T]) Fail ¶
func (arb *ApiDocResultBuilder[T]) Fail() *ApiDocResultBuilder[T]
func (*ApiDocResultBuilder[T]) Message ¶
func (arb *ApiDocResultBuilder[T]) Message(msg string) *ApiDocResultBuilder[T]
func (*ApiDocResultBuilder[T]) MessageWithFunc ¶
func (arb *ApiDocResultBuilder[T]) MessageWithFunc(fc func() string) *ApiDocResultBuilder[T]
func (*ApiDocResultBuilder[T]) StatusCode ¶
func (arb *ApiDocResultBuilder[T]) StatusCode(statusCode int) *ApiDocResultBuilder[T]
func (*ApiDocResultBuilder[T]) Success ¶
func (arb *ApiDocResultBuilder[T]) Success() *ApiDocResultBuilder[T]
type ApiResult ¶
func FailWithMsg ¶
func FailWithMsgFunc ¶
func SuccessVoid ¶
func SuccessVoid() ApiResult
func SuccessWithMsg ¶
func SuccessWithMsgFunc ¶
func (ApiResult) StatusCode ¶
type ApiResultBuilder ¶
type ApiResultBuilder struct {
// contains filtered or unexported fields
}
func NewApiResultBuilder ¶
func NewApiResultBuilder() *ApiResultBuilder
func (*ApiResultBuilder) Build ¶
func (arb *ApiResultBuilder) Build() ApiResult
func (*ApiResultBuilder) Data ¶
func (arb *ApiResultBuilder) Data(data interface{}) *ApiResultBuilder
func (*ApiResultBuilder) Fail ¶
func (arb *ApiResultBuilder) Fail() *ApiResultBuilder
func (*ApiResultBuilder) Message ¶
func (arb *ApiResultBuilder) Message(msg string) *ApiResultBuilder
func (*ApiResultBuilder) MessageWithFunc ¶
func (arb *ApiResultBuilder) MessageWithFunc(fc func() string) *ApiResultBuilder
func (*ApiResultBuilder) StatusCode ¶
func (arb *ApiResultBuilder) StatusCode(statusCode int) *ApiResultBuilder
func (*ApiResultBuilder) Success ¶
func (arb *ApiResultBuilder) Success() *ApiResultBuilder
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) EnableRouteAttributes ¶
func (builder *ControllerBuilder) EnableRouteAttributes()
EnableRouteAttributes enable route attributes, such as request parameters fields[0] is RequestBody or RequestGET/POST
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) SetRouteProcessor ¶
func (builder *ControllerBuilder) SetRouteProcessor(processor IRouterAttributeBuilder)
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 Descriptor 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, error)
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 IRouterAttributeBuilder ¶
type IRouterAttributeBuilder interface { Match(ctx *context.HttpContext, pathComponents []string) (string, bool) Insert(method, path string, handler func(ctx *context.HttpContext)) }
type MatchMvcInfo ¶
type Options ¶
type Options struct { Template *RouteTemplate ViewOption *view.Option }
type RequestBody ¶
type RequestBody struct { }
type RequestDelete ¶
type RequestDelete struct { }
type RequestGET ¶
type RequestGET struct { }
type RequestHead ¶
type RequestHead struct { }
type RequestOptions ¶
type RequestOptions struct { }
type RequestPOST ¶
type RequestPOST struct { }
type RequestPatch ¶
type RequestPatch struct{}
type RequestPut ¶
type RequestPut struct{}
type RouteAttribute ¶
type RouteAttribute struct { Template string `json:"routeTemplate"` Controller string `json:"controller"` Action string `json:"action"` Method string `json:"method"` }
func NewRouteAttribute ¶
func NewRouteAttribute(template string) RouteAttribute
type RouteAttributeCollection ¶
type RouteAttributeCollection struct { Collection map[string]RouteAttribute // contains filtered or unexported fields }
func NewRouteAttributeCollection ¶
func NewRouteAttributeCollection() *RouteAttributeCollection
func (*RouteAttributeCollection) Add ¶
func (collection *RouteAttributeCollection) Add(routeAttribute RouteAttribute)
func (*RouteAttributeCollection) Disable ¶
func (collection *RouteAttributeCollection) Disable()
func (*RouteAttributeCollection) Enable ¶
func (collection *RouteAttributeCollection) Enable()
func (*RouteAttributeCollection) HasElement ¶
func (collection *RouteAttributeCollection) HasElement() bool
func (*RouteAttributeCollection) IsEnable ¶
func (collection *RouteAttributeCollection) IsEnable() bool
func (*RouteAttributeCollection) Match ¶
func (collection *RouteAttributeCollection) Match(ctx *context.HttpContext, pathComponents []string, match *MatchMvcInfo) bool
func (*RouteAttributeCollection) SetProcessor ¶
func (collection *RouteAttributeCollection) SetProcessor(processor IRouterAttributeBuilder)
type RouteTemplate ¶
type RouteTemplate struct { Template string TemplateSplits []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, matchinfo *MatchMvcInfo) bool
type RouterHandler ¶
type RouterHandler struct { ControllerFilters []ActionFilterChain ControllerDescriptors map[string]ControllerDescriptor ActionRoutesAttributes *RouteAttributeCollection 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)
type StatusCoder ¶
type StatusCoder interface {
StatusCode() int
}
Source Files ¶
- IRouterAttributeBuilder.go
- action_descriptor.go
- action_executor_context.go
- action_filter.go
- action_filter_chain.go
- action_method_executor.go
- action_parameters_mapping_func.go
- api_controller.go
- api_result.go
- controller_activator.go
- controller_builder.go
- controller_descriptor.go
- options.go
- request_body.go
- route_attribute.go
- route_template.go
- router_handler.go
- router_handler_response.go
- status.coder.go