gin

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package gin provides a Gin implementation of the HTTP server abstraction.

Package gin provides a Gin implementation of the HTTP server abstraction.

Package gin provides a Gin implementation of the HTTP server abstraction.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewErrorHandlerMiddleware

func NewErrorHandlerMiddleware() middleware.IErrorHandlerMiddleware

NewErrorHandlerMiddleware creates a new ErrorHandlerMiddleware.

func NewLoggingMiddleware

func NewLoggingMiddleware() core.ILoggingMiddleware

NewLoggingMiddleware creates a new LoggingMiddleware.

Types

type Context

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

Context is an implementation of core.Context using the Gin framework.

func (*Context) Abort added in v0.0.6

func (c *Context) Abort()

Abort implements core.Context.Abort

func (*Context) Bind

func (c *Context) Bind(obj interface{}) error

Bind implements core.Context.Bind

func (*Context) BindJSON

func (c *Context) BindJSON(obj interface{}) error

BindJSON implements core.Context.BindJSON

func (*Context) DefaultQuery

func (c *Context) DefaultQuery(key, defaultValue string) string

DefaultQuery implements core.Context.DefaultQuery

func (*Context) Error

func (c *Context) Error(err error) error

Error implements core.Context.Error

func (*Context) Errors

func (c *Context) Errors() []error

Errors implements core.Context.Errors

func (*Context) File

func (c *Context) File(filepath string)

File implements core.Context.File

func (*Context) Get

func (c *Context) Get(key string) (interface{}, bool)

Get implements core.Context.Get

func (*Context) GetHeader

func (c *Context) GetHeader(key string) string

GetHeader implements core.Context.GetHeader

func (*Context) JSON

func (c *Context) JSON(code int, obj interface{})

JSON implements core.Context.JSON

func (*Context) Next

func (c *Context) Next()

Next implements core.Context.Next

func (*Context) Param

func (c *Context) Param(key string) string

Param implements core.Context.Param

func (*Context) Query

func (c *Context) Query(key string) string

Query implements core.Context.Query

func (*Context) Redirect

func (c *Context) Redirect(code int, location string)

Redirect implements core.Context.Redirect

func (*Context) Request

func (c *Context) Request() *http.Request

Request implements core.Context.Request

func (*Context) Set

func (c *Context) Set(key string, value interface{})

Set implements core.Context.Set

func (*Context) SetHeader

func (c *Context) SetHeader(key, value string)

SetHeader implements core.Context.SetHeader

func (*Context) SetStatus

func (c *Context) SetStatus(code int)

SetStatus implements core.Context.SetStatus

func (*Context) ShouldBindJSON

func (c *Context) ShouldBindJSON(obj interface{}) error

ShouldBindJSON implements core.Context.ShouldBindJSON

func (*Context) String

func (c *Context) String(code int, format string, values ...interface{})

String implements core.Context.String

func (*Context) Writer

func (c *Context) Writer() http.ResponseWriter

Writer implements core.Context.Writer

type ErrorHandlerMiddleware

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

ErrorHandlerMiddleware is a Gin-specific implementation of middleware.IErrorHandlerMiddleware.

func (*ErrorHandlerMiddleware) Middleware

Middleware returns a middleware function that handles errors for Gin.

type LoggingMiddleware

type LoggingMiddleware struct {
	middleware.BaseLoggingMiddleware
	// contains filtered or unexported fields
}

LoggingMiddleware is a Gin-specific implementation of core.ILoggingMiddleware. It works with the Gin framework (github.com/gin-gonic/gin).

func (*LoggingMiddleware) Middleware

func (m *LoggingMiddleware) Middleware(config *core.LoggingConfig) core.HandlerFunc

Middleware returns a middleware function that logs API requests for Gin. This implementation can capture the actual status code set by the handler.

type RouterGroup

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

RouterGroup is an implementation of core.RouterGroup using the Gin framework.

func (*RouterGroup) DELETE

func (g *RouterGroup) DELETE(path string, handlers ...core.HandlerFunc)

DELETE implements core.RouterGroup.DELETE

func (*RouterGroup) GET

func (g *RouterGroup) GET(path string, handlers ...core.HandlerFunc)

GET implements core.RouterGroup.GET

func (*RouterGroup) Group

func (g *RouterGroup) Group(path string) core.RouterGroup

Group implements core.RouterGroup.Group

func (*RouterGroup) PATCH

func (g *RouterGroup) PATCH(path string, handlers ...core.HandlerFunc)

PATCH implements core.RouterGroup.PATCH

func (*RouterGroup) POST

func (g *RouterGroup) POST(path string, handlers ...core.HandlerFunc)

POST implements core.RouterGroup.POST

func (*RouterGroup) PUT

func (g *RouterGroup) PUT(path string, handlers ...core.HandlerFunc)

PUT implements core.RouterGroup.PUT

func (*RouterGroup) RegisterRouter

func (g *RouterGroup) RegisterRouter(controllers ...core.Controller)

RegisterRouter implements core.RouterGroup.RegisterRouter

func (*RouterGroup) Use

func (g *RouterGroup) Use(middleware ...core.HandlerFunc)

Use implements core.RouterGroup.Use

type Server

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

Server is an implementation of core.Server using the Gin framework.

func NewServer

func NewServer(port string, showLogs bool) *Server

NewServer creates a new Server instance using the Gin framework. If showLogs is true, logs about the framework, middleware, and routes will be printed to the console. If showLogs is false, these logs will be suppressed.

func (*Server) DELETE

func (s *Server) DELETE(path string, handlers ...core.HandlerFunc)

DELETE implements core.Server.DELETE

func (*Server) GET

func (s *Server) GET(path string, handlers ...core.HandlerFunc)

GET implements core.Server.GET

func (*Server) GetErrorHandlerMiddleware

func (s *Server) GetErrorHandlerMiddleware() core.IErrorHandlerMiddleware

GetErrorHandlerMiddleware returns a Gin-specific error handler middleware.

func (*Server) GetLoggingMiddleware

func (s *Server) GetLoggingMiddleware() core.ILoggingMiddleware

GetLoggingMiddleware returns a Gin-specific logging middleware.

func (*Server) GetPort added in v0.1.3

func (s *Server) GetPort() string

GetPort implements core.Server.GetPort

func (*Server) Group

func (s *Server) Group(path string) core.RouterGroup

Group implements core.Server.Group

func (*Server) NoMethod

func (s *Server) NoMethod(handlers ...core.HandlerFunc)

NoMethod implements core.Server.NoMethod

func (*Server) NoRoute

func (s *Server) NoRoute(handlers ...core.HandlerFunc)

NoRoute implements core.Server.NoRoute

func (*Server) PATCH

func (s *Server) PATCH(path string, handlers ...core.HandlerFunc)

PATCH implements core.Server.PATCH

func (*Server) POST

func (s *Server) POST(path string, handlers ...core.HandlerFunc)

POST implements core.Server.POST

func (*Server) PUT

func (s *Server) PUT(path string, handlers ...core.HandlerFunc)

PUT implements core.Server.PUT

func (*Server) RegisterRouter

func (s *Server) RegisterRouter(controllers ...core.Controller)

RegisterRouter implements core.Server.RegisterRouter

func (*Server) Run

func (s *Server) Run() error

Run implements core.Server.Run

func (*Server) RunTLS

func (s *Server) RunTLS(addr, certFile, keyFile string) error

RunTLS implements core.Server.RunTLS

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown implements core.Server.Shutdown

func (*Server) StartLambda

func (s *Server) StartLambda() error

StartLambda starts the server in AWS Lambda mode. This method should be called instead of Run or RunTLS when running in AWS Lambda. This method uses the ginadapter library to convert the Gin engine to a Lambda handler.

Example usage:

import (
    "github.com/mythofleader/go-http-server"
)

func main() {
    s, _ := server.NewServer(server.FrameworkGin, "8080")
    // ... configure your server ...
    if err := s.StartLambda(); err != nil {
        // Handle error
    }
}

func (*Server) Stop added in v0.0.6

func (s *Server) Stop() error

Stop implements core.Server.Stop

func (*Server) Use

func (s *Server) Use(middleware ...core.HandlerFunc)

Use implements core.Server.Use

Jump to

Keyboard shortcuts

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