core

package module
v1.7.2 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 32 Imported by: 14

README

GoCondor Core

Build Status Test Status Coverage Status GoDoc Go Report Card

The core packages of GoCondor framework

Documentation

Index

Constants

View Source
const CONTENT_TYPE string = "content-Type"
View Source
const CONTENT_TYPE_HTML string = "text/html; charset=utf-8"
View Source
const CONTENT_TYPE_JSON string = "application/json"
View Source
const CONTENT_TYPE_MULTIPART_FORM_DATA string = "multipart/form-data;"
View Source
const CONTENT_TYPE_TEXT string = "text/plain"
View Source
const DELETE string = "delete"
View Source
const GET string = "get"
View Source
const HEAD string = "head"
View Source
const LOCALHOST string = "http://localhost"
View Source
const OPTIONS string = "options"
View Source
const PATCH string = "patch"
View Source
const POST string = "post"
View Source
const PRODUCTION string = "production"
View Source
const PUT string = "put"
View Source
const TEST_STR string = "Testing!"

Variables

This section is empty.

Functions

func DisableEvents added in v1.7.1

func DisableEvents()

func EnableEvents added in v1.7.1

func EnableEvents()

func NewGorm added in v1.5.0

func NewGorm() *gorm.DB

func ResolveGorm added in v1.5.0

func ResolveGorm() *gorm.DB

func UseMiddleware added in v1.5.0

func UseMiddleware(mw Middleware)

Types

type App

type App struct {
	Config *configContainer
	// contains filtered or unexported fields
}

func New

func New() *App

func ResolveApp added in v1.5.0

func ResolveApp() *App

func (*App) Bootstrap

func (app *App) Bootstrap()

func (*App) MakeDirs added in v1.7.1

func (app *App) MakeDirs(dirs ...string)

func (*App) Next added in v1.5.0

func (app *App) Next(c *Context)

func (*App) RegisterRoutes

func (app *App) RegisterRoutes(routes []Route, router *httprouter.Router) *httprouter.Router

func (*App) Run

func (app *App) Run(router *httprouter.Router)

func (*App) SetBasePath added in v1.7.1

func (app *App) SetBasePath(path string)

func (*App) SetCacheConfig added in v1.5.0

func (app *App) SetCacheConfig(c CacheConfig)

func (*App) SetGormConfig added in v1.5.0

func (app *App) SetGormConfig(g GormConfig)

func (*App) SetLogsDriver added in v1.5.0

func (app *App) SetLogsDriver(d logger.LogsDriver)

func (*App) SetRequestConfig added in v1.5.0

func (app *App) SetRequestConfig(r RequestConfig)

type Cache

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

func NewCache added in v1.5.0

func NewCache(cacheConfig CacheConfig) *Cache

func (*Cache) Delete added in v1.5.0

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

func (*Cache) Get added in v1.5.0

func (c *Cache) Get(key string) (string, error)

func (*Cache) Set added in v1.5.0

func (c *Cache) Set(key string, value string) error

func (*Cache) SetWithExpiration added in v1.5.0

func (c *Cache) SetWithExpiration(key string, value string, expiration time.Duration) error

type CacheConfig added in v1.5.0

type CacheConfig struct {
	EnableCache bool
}

type Context added in v1.5.0

type Context struct {
	Request          *Request
	Response         *Response
	GetValidator     func() *Validator
	GetJWT           func() *JWT
	GetGorm          func() *gorm.DB
	GetCache         func() *Cache
	GetHashing       func() *Hashing
	GetMailer        func() *Mailer
	GetEventsManager func() *EventsManager
	GetLogger        func() *logger.Logger
}

func (*Context) CastToFloat added in v1.5.0

func (c *Context) CastToFloat(value interface{}) float64

func (*Context) CastToInt added in v1.5.0

func (c *Context) CastToInt(value interface{}) int

func (*Context) CastToString added in v1.5.0

func (c *Context) CastToString(value interface{}) string

func (*Context) CopyFile added in v1.6.0

func (c *Context) CopyFile(sourceFilePath string, destFolderPath string) error

func (*Context) DebugAny added in v1.5.0

func (c *Context) DebugAny(variable interface{})

TODO enhance

func (*Context) GetBaseDirPath added in v1.5.0

func (c *Context) GetBaseDirPath() string

func (*Context) GetHeader added in v1.5.0

func (c *Context) GetHeader(key string) string

func (*Context) GetPathParam added in v1.5.0

func (c *Context) GetPathParam(key string) interface{}

func (*Context) GetRequestParam added in v1.5.0

func (c *Context) GetRequestParam(key string) interface{}

func (*Context) GetUploadedFile added in v1.5.0

func (c *Context) GetUploadedFile(name string) *UploadedFileInfo

func (Context) GetUserAgent added in v1.7.1

func (c Context) GetUserAgent() string

func (*Context) MapToJson added in v1.6.0

func (c *Context) MapToJson(v any) string

func (*Context) MoveFile added in v1.5.0

func (c *Context) MoveFile(sourceFilePath string, destFolderPath string) error

func (*Context) Next added in v1.5.0

func (c *Context) Next()

func (*Context) RequestParamExists added in v1.5.0

func (c *Context) RequestParamExists(key string) bool

type EmailAddress added in v1.6.0

type EmailAddress struct {
	Name    string // the name can be empty
	Address string // ex: john@example.com
}

type EmailAttachment added in v1.6.0

type EmailAttachment struct {
	Name string // name of the file
	Path string // full path to the file
}

type EnvFileConfig added in v1.5.0

type EnvFileConfig struct {
	UseDotEnvFile bool
}

type Event added in v1.7.0

type Event struct {
	Name    string
	Payload map[string]interface{}
}

type EventJob added in v1.7.0

type EventJob func(event *Event, requestContext *Context)

type EventsManager added in v1.7.0

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

func NewEventsManager added in v1.7.0

func NewEventsManager() *EventsManager

func ResolveEventsManager added in v1.7.0

func ResolveEventsManager() *EventsManager

func (*EventsManager) Fire added in v1.7.0

func (m *EventsManager) Fire(e *Event) error

func (*EventsManager) Register added in v1.7.0

func (m *EventsManager) Register(eName string, job EventJob)

type GormConfig added in v1.5.0

type GormConfig struct {
	EnableGorm bool
}

type Handler added in v1.5.0

type Handler func(c *Context) *Response

type Hashing added in v1.6.0

type Hashing struct{}

func (*Hashing) CheckPasswordHash added in v1.6.0

func (h *Hashing) CheckPasswordHash(hashedPassword string, originalPassowrd string) (bool, error)

func (*Hashing) HashPassword added in v1.6.0

func (h *Hashing) HashPassword(password string) (string, error)

type JWT added in v1.5.0

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

func (*JWT) DecodeToken added in v1.5.0

func (j *JWT) DecodeToken(token string) (payload map[string]interface{}, err error)

func (*JWT) GenerateToken added in v1.5.0

func (j *JWT) GenerateToken(payload map[string]interface{}) (string, error)

func (*JWT) HasExpired added in v1.5.0

func (j *JWT) HasExpired(token string) (bool, error)

type JWTConfig added in v1.5.0

type JWTConfig struct {
	SecretKey string
	Lifetime  int
}

type JWTOptions added in v1.5.0

type JWTOptions struct {
	SigningKey      string
	LifetimeMinutes int
}

type Mailer added in v1.6.0

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

func (*Mailer) Send added in v1.6.0

func (m *Mailer) Send() error

func (*Mailer) SetAttachments added in v1.6.0

func (m *Mailer) SetAttachments(attachments []EmailAttachment) *Mailer

func (*Mailer) SetBCC added in v1.6.0

func (m *Mailer) SetBCC(emailAddresses []EmailAddress) *Mailer

func (*Mailer) SetCC added in v1.6.0

func (m *Mailer) SetCC(emailAddresses []EmailAddress) *Mailer

func (*Mailer) SetFrom added in v1.6.0

func (m *Mailer) SetFrom(emailAddresses EmailAddress) *Mailer

func (*Mailer) SetHTMLBody added in v1.6.0

func (m *Mailer) SetHTMLBody(body string) *Mailer

func (*Mailer) SetPlainTextBody added in v1.6.0

func (m *Mailer) SetPlainTextBody(body string) *Mailer

func (*Mailer) SetSubject added in v1.6.0

func (m *Mailer) SetSubject(subject string) *Mailer

func (*Mailer) SetTo added in v1.6.0

func (m *Mailer) SetTo(emailAddresses []EmailAddress) *Mailer

type Middleware added in v1.6.0

type Middleware func(c *Context)

type Middlewares added in v1.5.0

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

func NewMiddlewares added in v1.5.0

func NewMiddlewares() *Middlewares

func ResolveMiddlewares added in v1.5.0

func ResolveMiddlewares() *Middlewares

func (*Middlewares) Attach added in v1.5.0

func (m *Middlewares) Attach(mw Middleware) *Middlewares

func (*Middlewares) GetMiddlewares added in v1.5.0

func (m *Middlewares) GetMiddlewares() []Middleware

type Request added in v1.5.0

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

type RequestConfig added in v1.5.0

type RequestConfig struct {
	MaxUploadFileSize int
}

type Response added in v1.5.0

type Response struct {
	HttpResponseWriter http.ResponseWriter
	// contains filtered or unexported fields
}

func (*Response) Any added in v1.6.0

func (rs *Response) Any(body any) *Response

TODO add doc

func (*Response) ForceSendResponse added in v1.6.0

func (rs *Response) ForceSendResponse()

func (*Response) HTML added in v1.6.0

func (rs *Response) HTML(body string) *Response

TODO add doc

func (*Response) Json added in v1.6.0

func (rs *Response) Json(body string) *Response

TODO add doc

func (*Response) Redirect added in v1.7.1

func (rs *Response) Redirect(url string) *Response

func (*Response) SetContentType added in v1.6.0

func (rs *Response) SetContentType(c string) *Response

TODO add doc

func (*Response) SetHeader added in v1.5.0

func (rs *Response) SetHeader(key string, val string) *Response

TODO add doc

func (*Response) SetStatusCode added in v1.6.0

func (rs *Response) SetStatusCode(code int) *Response

TODO add doc

func (*Response) Text added in v1.6.0

func (rs *Response) Text(body string) *Response

TODO add doc

type Route added in v1.5.0

type Route struct {
	Method      string
	Path        string
	Handler     Handler
	Middlewares []Middleware
}

type Router added in v1.5.0

type Router struct {
	Routes []Route
}

func NewRouter added in v1.5.0

func NewRouter() *Router

func ResolveRouter added in v1.5.0

func ResolveRouter() *Router

func (*Router) Delete added in v1.5.0

func (r *Router) Delete(path string, handler Handler, middlewares ...Middleware) *Router

func (*Router) Get added in v1.5.0

func (r *Router) Get(path string, handler Handler, middlewares ...Middleware) *Router

func (*Router) GetRoutes added in v1.5.0

func (r *Router) GetRoutes() []Route

func (*Router) Head added in v1.5.0

func (r *Router) Head(path string, handler Handler, middlewares ...Middleware) *Router

func (*Router) Options added in v1.5.0

func (r *Router) Options(path string, handler Handler, middlewares ...Middleware) *Router

func (*Router) Patch added in v1.5.0

func (r *Router) Patch(path string, handler Handler, middlewares ...Middleware) *Router

func (*Router) Post added in v1.5.0

func (r *Router) Post(path string, handler Handler, middlewares ...Middleware) *Router

func (*Router) Put added in v1.5.0

func (r *Router) Put(path string, handler Handler, middlewares ...Middleware) *Router

type UploadedFileInfo added in v1.5.0

type UploadedFileInfo struct {
	FullPath             string
	Name                 string
	NameWithoutExtension string
	Extension            string
	Size                 int
}

type Validator added in v1.5.0

type Validator struct{}

func (*Validator) Validate added in v1.5.0

func (v *Validator) Validate(data map[string]interface{}, rules map[string]interface{}) validationResult

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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