server

package
v0.0.0-...-392db30 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextMiddleware

func ContextMiddleware() gin.HandlerFunc

* This middlware adds a context ID to the request so we can track all requests from this user through the logs

func LoggingMiddleware

func LoggingMiddleware() gin.HandlerFunc

* This middleware logs primarily the request path, method, response status and completion latency

func RecoveryMiddlware

func RecoveryMiddlware(ctx *gin.Context, recovered interface{})

* This middleware prints a panic to the log and responds to the user with an error

func SetupRouter

func SetupRouter() *gin.Engine

Types

type Server

type Server struct {
	Config    config.Config
	HTTP      *http.Server
	Datastore *database.Datastore
}

func NewServer

func NewServer(config config.Config) *Server

NewServer returns an initialized Server

func (*Server) MiscV2BrewGet

func (s *Server) MiscV2BrewGet(c *gin.Context)

MiscV2BrewGet godoc @Summary Brew coffee @Description Responds with refusal to brew coffee @Tags V2 @Produce json @Success 200 {object} helpers.Error @Router /v2/brew [get]

func (*Server) MiscV2HealthcheckGet

func (s *Server) MiscV2HealthcheckGet(c *gin.Context)

MiscV2HealthcheckGet godoc @Summary Get health of API @Description Responds with any service errors @Tags V2 @Produce json @Success 200 {object} helpers.Empty @Success 503 {object} helpers.ErrorsArray @Failure 500 {object} helpers.Error @Router /v2/healthcheck [get]

func (*Server) MiscV2PingGet

func (s *Server) MiscV2PingGet(c *gin.Context)

MiscV2PingGet godoc @Summary Ping pong @Description Responds with a pong @Tags V2 @Produce json @Success 200 {object} helpers.Message @Router /v2/ping [get]

func (*Server) RootGet

func (s *Server) RootGet(c *gin.Context)

RootGet godoc @Summary Redirect to swagger docs @Description Redirect to swagger docs @Tags Root @Success 307 @Header 307 {string} Location "docs/index.html" @Router / [get]

func (*Server) RootV2Get

func (s *Server) RootV2Get(c *gin.Context)

MiscV2HealthcheckGet godoc @Summary Get health of API @Description Responds with 'Root V2' message @Tags V2 @Produce json @Success 200 {object} helpers.Message @Router /v2 [get]

func (*Server) Start

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

Start begins listening

func (*Server) Stop

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

Stop shuts down the server and listener

Jump to

Keyboard shortcuts

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