libGin

package
v2.0.0-...-51e8ac7 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package libGin provides the v2 Gin web framework adapter for requestCore.

It embeds the v1 github.com/hmmftg/requestCore/libGin.GinParser and adds raw response writing, cookie access, and v2 routing support.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GinParserV2

type GinParserV2 struct {
	legacyLibGin.GinParser
	// contains filtered or unexported fields
}

GinParserV2 extends the v1 GinParser with raw response writing and cookie access for v2 renderer and session support.

func InitContextV2

func InitContextV2(c any) *GinParserV2

InitContextV2 creates a GinParserV2 from a Gin context.

func (*GinParserV2) GetCookie

func (p *GinParserV2) GetCookie(name string) string

GetCookie returns the value of the named request cookie.

func (*GinParserV2) SendResponse

func (p *GinParserV2) SendResponse(status int, contentType string, body []byte) error

SendResponse writes a raw response with the given status, content type, and body bytes to the Gin response writer. If a CommitState is bound and already committed, this method returns nil without writing. Before writing, the before-commit hook runner is invoked (if set) so that session cookies and other pre-write side effects are persisted even for direct parser writes.

func (*GinParserV2) SetBeforeCommitHookRunner

func (p *GinParserV2) SetBeforeCommitHookRunner(fn func() error)

SetBeforeCommitHookRunner binds a function that runs before-commit hooks before SendResponse writes the response.

func (*GinParserV2) SetCommitState

func (p *GinParserV2) SetCommitState(cs *v2wf.CommitState)

SetCommitState binds the request's CommitState to this parser so that SendResponse can check and update the committed status.

func (*GinParserV2) SetCookie

func (p *GinParserV2) SetCookie(cookie *http.Cookie)

SetCookie sets an HTTP response cookie on the Gin response.

type GinRouter

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

GinRouter implements routing.Router and routing.RouteGroup for Gin.

func NewRouter

func NewRouter(engine *gin.Engine) *GinRouter

NewRouter creates a new GinRouter from a Gin engine.

func NewRouterFromGroup

func NewRouterFromGroup(group *gin.RouterGroup) *GinRouter

NewRouterFromGroup creates a new GinRouter from an existing Gin RouterGroup.

func (*GinRouter) Delete

func (r *GinRouter) Delete(pattern string, handler routing.Handler) error

Delete registers a DELETE handler.

func (*GinRouter) Get

func (r *GinRouter) Get(pattern string, handler routing.Handler) error

Get registers a GET handler.

func (*GinRouter) Group

func (r *GinRouter) Group(prefix string) routing.RouteGroup

Group creates a sub-group with the given prefix.

func (*GinRouter) Handle

func (r *GinRouter) Handle(method, pattern string, handler routing.Handler) error

Handle registers a handler for the given method and pattern.

func (*GinRouter) Head

func (r *GinRouter) Head(pattern string, handler routing.Handler) error

Head registers a HEAD handler.

func (*GinRouter) MethodNotAllowed

func (r *GinRouter) MethodNotAllowed(handler routing.Handler)

MethodNotAllowed sets the handler for disallowed methods. This requires an engine scope; calling it on a group-only router panics.

func (*GinRouter) Native

func (r *GinRouter) Native() any

Native returns the underlying Gin engine or router group.

func (*GinRouter) NotFound

func (r *GinRouter) NotFound(handler routing.Handler)

NotFound sets the handler for unmatched routes. This requires an engine scope; calling it on a group-only router (created via NewRouterFromGroup) panics because 404 registration is engine-wide.

func (*GinRouter) Patch

func (r *GinRouter) Patch(pattern string, handler routing.Handler) error

Patch registers a PATCH handler.

func (*GinRouter) Post

func (r *GinRouter) Post(pattern string, handler routing.Handler) error

Post registers a POST handler.

func (*GinRouter) Put

func (r *GinRouter) Put(pattern string, handler routing.Handler) error

Put registers a PUT handler.

func (*GinRouter) SetErrorHandler

func (r *GinRouter) SetErrorHandler(handler *response.Handler)

SetErrorHandler installs the v2 response handler and error registry used for centralized error dispatch. When set, handler errors are routed through the registry instead of emitting hard-coded 500 responses.

func (*GinRouter) With

func (r *GinRouter) With(middleware ...routing.Middleware) routing.RouteGroup

With returns a new group with additional middleware.

Jump to

Keyboard shortcuts

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