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 ¶
- type GinParserV2
- func (p *GinParserV2) GetCookie(name string) string
- func (p *GinParserV2) SendResponse(status int, contentType string, body []byte) error
- func (p *GinParserV2) SetBeforeCommitHookRunner(fn func() error)
- func (p *GinParserV2) SetCommitState(cs *v2wf.CommitState)
- func (p *GinParserV2) SetCookie(cookie *http.Cookie)
- type GinRouter
- func (r *GinRouter) Delete(pattern string, handler routing.Handler) error
- func (r *GinRouter) Get(pattern string, handler routing.Handler) error
- func (r *GinRouter) Group(prefix string) routing.RouteGroup
- func (r *GinRouter) Handle(method, pattern string, handler routing.Handler) error
- func (r *GinRouter) Head(pattern string, handler routing.Handler) error
- func (r *GinRouter) MethodNotAllowed(handler routing.Handler)
- func (r *GinRouter) Native() any
- func (r *GinRouter) NotFound(handler routing.Handler)
- func (r *GinRouter) Patch(pattern string, handler routing.Handler) error
- func (r *GinRouter) Post(pattern string, handler routing.Handler) error
- func (r *GinRouter) Put(pattern string, handler routing.Handler) error
- func (r *GinRouter) SetErrorHandler(handler *response.Handler)
- func (r *GinRouter) With(middleware ...routing.Middleware) routing.RouteGroup
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 NewRouterFromGroup ¶
func NewRouterFromGroup(group *gin.RouterGroup) *GinRouter
NewRouterFromGroup creates a new GinRouter from an existing Gin RouterGroup.
func (*GinRouter) Group ¶
func (r *GinRouter) Group(prefix string) routing.RouteGroup
Group creates a sub-group with the given prefix.
func (*GinRouter) MethodNotAllowed ¶
MethodNotAllowed sets the handler for disallowed methods. This requires an engine scope; calling it on a group-only router panics.
func (*GinRouter) NotFound ¶
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) SetErrorHandler ¶
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.