mvc

package
v2.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

func Apply(e *gin.Engine, autowired bool)

Apply all apis to the gin engine @param e: gin.Engine @param autowired: whether enable autowired properties

func GetAnnotation added in v2.2.0

func GetAnnotation(ctx *gin.Context, annotationName string) (val string, has bool)

GetAnnotation Gets the specified annotation Returns the value of this annotation, when the has is false mine this val is empty

func IsController

func IsController(v interface{}) bool

IsController Determine whether it is controller

func Register

func Register(controller ...abstractController)

Register controllers

Types

type Annotations added in v2.2.0

type Annotations map[string]string

Annotations the annotation of Api method

type Controller

type Controller struct{}

Controller Default abstract controller implementation.

Simply integrate the default controller into your structure.

Example:

type YourController struct {
   mvc.Controller
}

// Hello
// @GET(path="/hello") this is api method
func (y *YourController) Hello(ctx *gin.Context) {
   resp.Json(ctx, "Hello World")
}

// Access the API
curl http://localhost:4006/hello

func (*Controller) PostConstruct

func (c *Controller) PostConstruct()

type MethodInterceptor

type MethodInterceptor interface {
	// Predicate true means intercept.
	Predicate(ctx *gin.Context) bool

	// PreHandle triggered before method invocation.
	// If you want to abort the current request, just call abort() and response inside the method
	PreHandle(ctx *gin.Context)

	// PostHandle triggered after method invocation.
	// If you want to abort the current request, just call abort() and response inside the method
	PostHandle(ctx *gin.Context)
}

MethodInterceptor API method interceptor You can do logical processing before and after method calls

Jump to

Keyboard shortcuts

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