stdlib

package
v0.0.0-...-cec8604 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCache

func NewCache() cache.Cache

NewCache will create a new instance of the built-in cache

Types

type Cache

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

func (*Cache) Contains

func (m *Cache) Contains(key string) (bool, error)

Contains returns whether a key is present in the cache

func (*Cache) Delete

func (m *Cache) Delete(key string) error

Delete removes a cache entry by its key, will do nothing if the key was not present in the cache It will also cancel any existing expirations for the given key

func (*Cache) ExpireAfter

func (m *Cache) ExpireAfter(key string, duration time.Duration) error

ExpireAfter will mark a cache key for expiration after a certain duration

func (*Cache) Get

func (m *Cache) Get(key string, out interface{}) error

Get will attempt to read a stored cache value into the given out interface pointer or error if not present

func (*Cache) GetOrDefault

func (m *Cache) GetOrDefault(key string, out interface{}, def interface{}) error

Get will attempt to read a stored cache value into the given out interface pointer or return default if not found

func (*Cache) Set

func (m *Cache) Set(key string, val interface{}) error

Set will attempt to store a value in the cache with a given key It will also reset any expirations set for the given key

type Renderer

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

func NewRenderer

func NewRenderer() *Renderer

func (Renderer) Render

func (b Renderer) Render(view string, bag renderer.ViewBag) (string, error)

Render will load a template file and render the template within using the viewbag as a context

func (*Renderer) SetTemplateDir

func (b *Renderer) SetTemplateDir(path string) error

SetTemplateDir will set the base directory where views are located

func (Renderer) TemplateDir

func (b Renderer) TemplateDir() string

TemplateDir will return the absolute path of the configured templates directory

type Router

type Router struct {
	Middleware []interface{}
	Routes     []router.Handler
	Router     *httprouter.Router
	Server     *http.Server

	ErrorHandler router.Handler
}

func NewRouter

func NewRouter() *Router

NewRouter will create new instance of the mojito stdlib router implementation

func (*Router) CONNECT

func (r *Router) CONNECT(path string, handler interface{}) error

CONNECT will add a route to this router for the connect method

func (*Router) DELETE

func (r *Router) DELETE(path string, handler interface{}) error

DELETE will add a route to this router for the delete method

func (*Router) GET

func (r *Router) GET(path string, handler interface{}) error

GET will add a route to this router for the get method

func (*Router) HEAD

func (r *Router) HEAD(path string, handler interface{}) error

HEAD will add a route to this router for the head method

func (*Router) ListenAndServe

func (r *Router) ListenAndServe(address string) error

ListenAndServe will start an HTTP webserver on the given address

func (*Router) ListenAndServeTLS

func (r *Router) ListenAndServeTLS(address string, certFile string, keyFile string) error

ListenAndServeTLS will start an HTTP/S webserver on the given address

func (*Router) OPTIONS

func (r *Router) OPTIONS(path string, handler interface{}) error

OPTIONS will add a route to this router for the options method

func (*Router) PATCH

func (r *Router) PATCH(path string, handler interface{}) error

PATCH will add a route to this router for the patch method

func (*Router) POST

func (r *Router) POST(path string, handler interface{}) error

POST will add a route to this router for the post method

func (*Router) PUT

func (r *Router) PUT(path string, handler interface{}) error

PUT will add a route to this router for the put method

func (*Router) Shutdown

func (r *Router) Shutdown() error

Shutdown will gracefully shutdown the router

func (*Router) TRACE

func (r *Router) TRACE(path string, handler interface{}) error

TRACE will add a route to this router for the trace method

func (*Router) WithErrorHandler

func (r *Router) WithErrorHandler(handler interface{}) error

WithErrorHandler will set the error handler for the router

func (*Router) WithGroup

func (r *Router) WithGroup(path string, callback func(group router.Group)) error

WithGroup will create a new route group for the given prefix

func (*Router) WithMethodNotAllowedHandler

func (r *Router) WithMethodNotAllowedHandler(handler interface{}) error

WithMethodNotAllowedHandler will set the not allowed handler for the router

func (*Router) WithMiddleware

func (r *Router) WithMiddleware(handler interface{}) error

WithMiddleware will add a middleware to the router

func (*Router) WithNotFoundHandler

func (r *Router) WithNotFoundHandler(handler interface{}) error

WithNotFoundHandler will set the not found handler for the router

func (*Router) WithRoute

func (r *Router) WithRoute(method string, path string, handler interface{}) error

WithRoute will add a new route with the given RouteMethod to the router

Jump to

Keyboard shortcuts

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