rest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package rest implements a REST application and auxiliary.

Index

Constants

View Source
const (
	// ID defines a base id of all other rest
	// package instances registered in the application container.
	ID = api.ID + ".rest"

	// EngineID defines the id to be used as the
	// container registration id of the rest engine instance.
	EngineID = ID + ".engine"

	// ProcessID defines the id to be used as the
	// container registration id of the rest watchdog process.
	ProcessID = ID + ".process"

	// EndpointRegisterTag defines the tag to be used as the
	// identification of a controller's registration instance.
	EndpointRegisterTag = ID + ".register"
)
View Source
const (
	// EnvID defines the slate.api.rest package base environment variable name.
	EnvID = api.EnvID + "_REST"
)

Variables

View Source
var (
	// ConfigPath defines the configuration location where is
	// defined the REST service configuration.
	ConfigPath = env.String(EnvID+"_CONFIG_PATH", "slate.api.rest")

	// WatchdogName defines the default REST service watchdog name.
	WatchdogName = env.String(EnvID+"_WATCHDOG_NAME", "rest")

	// Port defines the default rest service port.
	Port = env.Int(EnvID+"_PORT", 80)

	// LogChannel defines the default logging channel.
	LogChannel = env.String(EnvID+"_LOG_CHANNEL", "rest")

	// LogLevel defines the default logging level.
	LogLevel = env.String(EnvID+"_LOG_LEVEL", "info")

	// LogStartMessage defines the default service start logging message.
	LogStartMessage = env.String(EnvID+"_LOG_START_MESSAGE", "[service:rest] service starting ...")

	// LogErrorMessage defines the default service error logging message.
	LogErrorMessage = env.String(EnvID+"_LOG_ERROR_MESSAGE", "[service:rest] service error")

	// LogEndMessage defines the default service end logging message.
	LogEndMessage = env.String(EnvID+"_LOG_END_MESSAGE", "[service:rest] service terminated")
)

Functions

This section is empty.

Types

type Engine

type Engine interface {
	gin.IRoutes
	Delims(left, right string) *gin.Engine
	HandleContext(c *gin.Context)
	LoadHTMLFiles(files ...string)
	LoadHTMLGlob(pattern string)
	NoMethod(handlers ...gin.HandlerFunc)
	NoRoute(handlers ...gin.HandlerFunc)
	Routes() (routes gin.RoutesInfo)
	Run(addr ...string) (err error)
	RunFd(fd int) (err error)
	RunListener(listener net.Listener) (err error)
	RunTLS(addr, certFile, keyFile string) (err error)
	RunUnix(file string) (err error)
	SecureJsonPrefix(prefix string) *gin.Engine
	ServeHTTP(w http.ResponseWriter, req *http.Request)
	SetFuncMap(funcMap template.FuncMap)
	SetHTMLTemplate(tpl *template.Template)
}

Engine interface for the gin-gonic engine object.

type IEndpointRegister

type IEndpointRegister interface {
	Reg(engine Engine) error
}

IEndpointRegister defines an interface to an instance that is able to register endpoints to the REST engine/service

type Middleware

type Middleware func(gin.HandlerFunc) gin.HandlerFunc

Middleware defines a type of data that represents a rest method middleware function.

type Process

type Process struct {
	*watchdog.Process
}

Process defines the REST watchdog process instance.

func NewProcess

func NewProcess(
	cfgManager config.IManager,
	logger log.ILog,
	engine Engine,
) (*Process, error)

NewProcess will try to instantiate an REST watchdog process.

type Provider

type Provider struct{}

Provider defines the REST services provider instance.

func (Provider) Boot

func (p Provider) Boot(
	container ...slate.IContainer,
) error

Boot will start the REST engine with the defined controllers.

func (Provider) Register

func (p Provider) Register(
	container ...slate.IContainer,
) error

Register will register the REST section instances in the application container.

Directories

Path Synopsis
Package envelopemw implements Gin-Gonic middleware to be used as a way to guarantee the response normalization throw the envelope defined structure.
Package envelopemw implements Gin-Gonic middleware to be used as a way to guarantee the response normalization throw the envelope defined structure.
Package logmw implements Gin-Gonic middleware to be used as a way to provide a REST logging normalized process.
Package logmw implements Gin-Gonic middleware to be used as a way to provide a REST logging normalized process.

Jump to

Keyboard shortcuts

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