http

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ProxyPath = "/proxy"
)

Functions

func Error

func Error(c *gin.Context, err error)

Error responses error message and set the http status code 500.

func NoContent

func NoContent(c *gin.Context)

NoContent responses with empty content and set the http status code 204.

func NotFound

func NotFound(c *gin.Context)

NotFound responses resource not found.

func OK

func OK(c *gin.Context, content interface{})

OK responses with content and set the http status code 200.

Types

type ProxyParam added in v0.2.4

type ProxyParam struct {
	Target string `form:"target" binding:"required"`
	Path   string `form:"path" binding:"required"`
}

ProxyParam represents proxy request params.

type ReverseProxy added in v0.2.4

type ReverseProxy struct {
}

ReverseProxy represents the http reverse proxy to target's api.

func NewReverseProxy added in v0.2.4

func NewReverseProxy() *ReverseProxy

NewReverseProxy creates a ReverseProxy instance.

func (*ReverseProxy) Proxy added in v0.2.4

func (p *ReverseProxy) Proxy(c *gin.Context)

Proxy forwards to target server api by given target ip and path.

@Summary reverse proxy @Description Forward request to target server by given target ip and path. @Tags State @Accept json @Param param body models.ProxyParam ture "param data" @Produce json @Success 200 {object} object @Failure 404 {string} string "not found" @Failure 500 {string} string "validate failure" @Failure 500 {string} string "internal error" @Router /proxy [get]

func (*ReverseProxy) Register added in v0.2.4

func (p *ReverseProxy) Register(route gin.IRoutes)

Register adds proxy url route.

type RouteRegister

type RouteRegister interface {
	// Register adds url route.
	Register(gin.IRoutes)
}

RouteRegister represents http handle register for spec route path.

type Server

type Server interface {
	// GetAPIRouter returns api router.
	GetAPIRouter() *gin.RouterGroup
	// Run runs the HTTP server.
	Run() error
	// Close closes the server.
	Close(ctx context.Context) error
}

Server represents http server with gin framework.

func NewServer

func NewServer(cfg config.HTTP, staticResource bool, r *linmetric.Registry) Server

NewServer creates http server.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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