rest

package
v0.0.0-...-a9081ec Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package rest provides a server and handlers for RESTful HTTP requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

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

Server provides HTTP routing and handler dependencies.

func NewServer

func NewServer(
	logger *otelzap.Logger,
	handler *gin.Engine,
	cfg *configs.Config,
) *Server

NewServer returns a new hexagonal server configured using the provided Config.

func (*Server) GracefulShutdown

func (s *Server) GracefulShutdown() error

GracefulShutdown closes the Server with the grace period specified in its config.

func (*Server) Run

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

Run starts the Server in a new goroutine, forwarding any errors to its errorStream. Run blocks until either a server error or an OS interrupt occurs. In the case of an interrupt, Run first attempts to shut down gracefully.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP calls the ServeHTTP method of the Server's underlying handler, passing through its ResponseWriter and Request. This is router-agnostic and makes the server exceptionally easy to test.

type ServerMiddleware

type ServerMiddleware []gin.HandlerFunc

ServerMiddleware represents a chain of middleware in the order in which they'll be applied to a *gin.Engine. I.e. the first middleware in the stack represents the outermost layer in the HTTP call chain.

func GlobalServerMiddleware

func GlobalServerMiddleware(logger *otelzap.Logger) ServerMiddleware

GlobalServerMiddleware returns the middleware stack used for all routes when running in development.

Directories

Path Synopsis
admin
profile/adminsettinghandler
Package adminsettinghandler provide a server and handlers for RESTful HTTP requests.
Package adminsettinghandler provide a server and handlers for RESTful HTTP requests.
authentication
authenticationhandler
Package authenticationhandler provide a server and handlers for RESTful HTTP requests.
Package authenticationhandler provide a server and handlers for RESTful HTTP requests.
Package gincontext provides funtcion to get ent entity from gin context
Package gincontext provides funtcion to get ent entity from gin context
Package middlewares provide a middleware used in handlers for RESTful HTTP requests.
Package middlewares provide a middleware used in handlers for RESTful HTTP requests.

Jump to

Keyboard shortcuts

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