handler

package
v0.0.0-...-dd6da27 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Crash

func Crash(server *http.Server) func(ctx *gin.Context)

Crash will make dobby to kill itself As dobby dies, the gin server also shuts down. @Summary Suicide @Description Make Dobby kill itself @Tags Control @Accept json @Router /control/crash [put]

func GoTurboCPU

func GoTurboCPU(c *gin.Context)

GoTurboCPU will make dobby go Turbo Watch the video `https://youtu.be/TNjAZZ3vQ8o?t=14` for more context on `Going Turbo` @Summary CPU Spike @Description Make Dobby create a CPU spike @Tags Control @Accept json @Produce json @Success 200 {object} model.ControlSuccess @Router /control/goturbo/cpu [put]

func GoTurboMemory

func GoTurboMemory(c *gin.Context)

GoTurboMemory will make dobby go Turbo Watch the video `https://youtu.be/TNjAZZ3vQ8o?t=14` for more context on `Going Turbo` @Summary Memory Spike @Description Make Dobby create a memory spike @Tags Control @Accept json @Produce json @Success 200 {object} model.ControlSuccess @Router /control/goturbo/memory [put]

Types

type Context

type Context interface {
	JSON(code int, obj interface{})
	GetRequestBody() io.ReadCloser
	Status(code int)
	GetURI() *url.URL
	GetMethod() string
	SendResponse(response *http.Response, url string)
}

Context is the interface represents the minimalistic gin.Context this is used to create mock struct while testing

func NewDefaultContext

func NewDefaultContext(c *gin.Context) Context

NewDefaultContext creates the wrapper Context with gin Context

type Handler

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

Handler is provides HandlerFunc for Gin Context

func New

func New(initialHealth, initialReadiness bool, httpClient httpClient) *Handler

New creates a new Handler

func (*Handler) AddProxy

func (h *Handler) AddProxy(c Context)

AddProxy allows to configure proxy to any existing endpoint @Summary Add proxy to any http endpoint @Description Configure proxy route to another endpoint @Description Supports all REST operations @Tags Feature @Accept json @Produce json @Success 200 {object} interface{} @Router /proxy [post] @Param body body proxyRequest true "'{path:/time, method: GET, proxy: {url:http://worldtimeapi.org/api/timezone/asia/kolkata, method:GET}}'"

func (*Handler) Call

func (h *Handler) Call(c Context)

Call allows to make a http call to another service and send the response @Summary Call a http endpoint @Description Make a http call to another service and send the response @Description Supports all REST operations @Tags Feature @Accept json @Produce json @Success 200 {object} interface{} @Router /call [post] @Param body body model.CallRequest true "'{url: http://httpbin.org/post, method: POST, body: {key: value}}' will make a post request to http://httpbin.org/post" https://github.com/swaggo/swag/blob/3d90fc0a5c6ef9566df81fe34425b0b35b0f651e/operation.go#L184

func (*Handler) DeleteProxy

func (h *Handler) DeleteProxy(c Context)

DeleteProxy allows to remove configured proxy to any existing endpoint @Summary Delete configured proxy to any http endpoint @Description Delete configured proxy route to another endpoint @Description Supports all REST operations @Tags Feature @Accept json @Produce json @Success 200 {object} interface{} @Router /proxy [delete] @Param body body proxyRequest true "'{path:/time, method: GET, proxy: {url:http://worldtimeapi.org/api/timezone/asia/kolkata, method:GET}}'"

func (*Handler) HTTPStat

func (h *Handler) HTTPStat(c *gin.Context)

HTTPStat returns the status code send by the client @Summary Repeat Status @Description Ask Dobby to return the status code sent by the client @Tags Status @Accept json @Produce json @Failure 400 {object} model.Error @Param statusCode path int true "Status Code - E.g. 200" @Param delay query int false "Dela(milliseconds) - E.g. 1000" @Router /return/{statusCode} [get]

func (*Handler) Health

func (h *Handler) Health(c *gin.Context)

Health return the dobby health status @Summary Dobby Health @Description Get Dobby's health status @Tags Status @Accept json @Produce json @Success 200 {object} model.Health @Failure 500 {object} model.Health @Router /health [get]

func (*Handler) MakeHealthPerfect

func (h *Handler) MakeHealthPerfect(c *gin.Context)

MakeHealthPerfect godoc @Summary Make Healthy @Description Make Dobby healthy @Tags Control @Accept json @Produce json @Success 200 {object} model.ControlSuccess @Router /control/health/perfect [put]

func (*Handler) MakeHealthSick

func (h *Handler) MakeHealthSick(c *gin.Context)

MakeHealthSick godoc @Summary Make Unhealthy @Description Make Dobby sick or unhealthy @Tags Control @Accept json @Produce json @Param resetInSeconds query int false "Recover health after sometime (seconds) - E.g. 2" @Success 200 {object} model.ControlSuccess @Router /control/health/sick [put]

func (*Handler) MakeReadyPerfect

func (h *Handler) MakeReadyPerfect(c *gin.Context)

MakeReadyPerfect godoc @Summary Make Ready @Description Make Dobby ready @Tags Control @Accept json @Produce json @Success 200 {object} model.ControlSuccess @Router /control/ready/perfect [put]

func (*Handler) MakeReadySick

func (h *Handler) MakeReadySick(c *gin.Context)

MakeReadySick godoc @Summary Make Unready @Description Make Dobby unready @Tags Control @Accept json @Produce json @Success 200 {object} model.ControlSuccess @Param resetInSeconds query int false "Recover readiness after sometime (seconds) - E.g. 2" @Router /control/ready/sick [put]

func (*Handler) Meta

func (h *Handler) Meta(c *gin.Context)

Meta return dobby's metadata @Summary Dobby Metadata @Description Get Dobby's metadata @Tags Status @Accept json @Produce json @Success 200 {object} model.Metadata @Failure 503 {object} model.Error @Failure 500 {object} model.Error @Router /meta [get]

func (*Handler) ProxyRoute

func (h *Handler) ProxyRoute(c Context)

ProxyRoute will route to custom route if the route is found in proxyRequests this will be invoked when no standard routes are found in gin

func (*Handler) Ready

func (h *Handler) Ready(c *gin.Context)

Ready return the dobby health status @Summary Dobby Ready @Description Get Dobby's readiness @Tags Status @Accept json @Produce json @Success 200 {object} model.Ready @Failure 503 {object} model.Ready @Router /ready [get]

func (*Handler) Version

func (h *Handler) Version(c *gin.Context)

Version return dobby version @Summary Dobby Version @Description Get Dobby's version @Tags Status @Accept json @Produce json @Success 200 {object} model.Version @Failure 503 {object} model.Error @Failure 500 {object} model.Error @Router /version [get]

Jump to

Keyboard shortcuts

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