slaterest

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: MIT Imports: 14 Imported by: 0

README

slaterest

Opinionated golang application framework for REST API's

  • slaterest
    • srlog
    • srenvelope
    • srvalidator
    • srcache
    • srhealth

Documentation

Index

Constants

View Source
const (
	// ContainerID defines the slate.slaterest package container entry id base string.
	ContainerID = slate.ContainerID + ".slaterest"

	// ContainerEngineID defines the default id used to register the
	// application gin engine instance in the application container.
	ContainerEngineID = ContainerID + ".engine"
)
View Source
const (
	// EnvID defines the slate.slaterest package base environment variable name.
	EnvID = slate.EnvID + "_SREST"
)

Variables

View Source
var (
	// ConfigPortPath contains the config path of the server port to be used.
	ConfigPortPath = senv.String(EnvID+"_CONFIG_PORT_PATH", "server.port")

	// LogChannel contains the name of the logging channel to be used on
	// the slaterest application messages.
	LogChannel = senv.String(EnvID+"_LOG_CHANNEL", "exec")
)

Functions

func GetEngine

func GetEngine(c slate.ServiceContainer) (*gin.Engine, error)

GetEngine will try to retrieve the registered gin engine instance from the application service container.

Types

type Application

type Application struct {
	slate.Application
	// contains filtered or unexported fields
}

Application defines an object for a slaterest api project.

func NewApplication

func NewApplication() *Application

NewApplication used to instantiate a new application.

func (Application) Engine

func (a Application) Engine() Engine

Engine returns the reference to the instantiated gin-gonic engine

func (Application) Run

func (a Application) Run(addr ...string) (err error)

Run method will boot the application, if not yet, and the start the underlying gin server.

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 Middleware

type Middleware func(gin.HandlerFunc) gin.HandlerFunc

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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