raptor

package module
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 17 Imported by: 23

README

Raptor

Raptor

Go MVC web development eco-system based on Fiber and heavily inspired by Ruby on Rails and Buffalo.

Installation

go get github.com/go-raptor/raptor

Example

Check out the repositories for an example:

Documentation

Index

Constants

View Source
const (
	DefaultGeneralConfigDevelopment = false

	DefaultServerConfigAddress = "127.0.0.1"
	DefaultServerConfigPort    = 3000
	DefaultShutdownTimeout     = 3
	DefaultProxyHeader         = ""

	DefaultDatabaseConfigType = "none"
	DefaultDatabaseConfigHost = "localhost"
	DefaultDatabaseConfigPort = 5432
	DefaultDatabaseConfigUser = "AppConfig"
	DefaultDatabaseConfigPass = ""
	DefaultDatabaseConfigName = "AppConfig"

	DefaultTemplatingConfigEnabled = false

	DefaultStaticConfigEnabled = true
	DefaultStaticConfigPrefix  = "/public"
	DefaultStaticConfigRoot    = "./public"

	DefaultCORSConfigOrigins     = "*"
	DefaultCORSConfigCredentials = false
)
View Source
const (
	Version = "v0.9.1"
)

Variables

This section is empty.

Functions

func Use added in v0.9.0

func Use(h fiber.Handler) *fiberMiddleware

Types

type AppInitializer

type AppInitializer struct {
	Database    Database
	Middlewares Middlewares
	Services    Services
	Controllers Controllers
	Template    Template
}

type CORSConfig added in v0.6.0

type CORSConfig struct {
	Origins     []string
	Credentials bool
}

type Config

type Config struct {
	GeneralConfig    GeneralConfig          `toml:"General"`
	ServerConfig     ServerConfig           `toml:"Server"`
	DatabaseConfig   DatabaseConfig         `toml:"Database"`
	TemplatingConfig TemplatingConfig       `toml:"Templating"`
	StaticConfig     StaticConfig           `toml:"Static"`
	CORSConfig       CORSConfig             `toml:"CORS"`
	AppConfig        map[string]interface{} `toml:"App"`
	// contains filtered or unexported fields
}

func (*Config) ApplyEnvirontmentVariable added in v0.6.3

func (c *Config) ApplyEnvirontmentVariable(key string, value interface{})

func (*Config) ApplyEnvirontmentVariables added in v0.6.3

func (c *Config) ApplyEnvirontmentVariables()

type Connector added in v0.6.0

type Connector interface {
	Connect(config interface{}) (*gorm.DB, error)
}

type Context

type Context struct {
	*fiber.Ctx
	Controller string
	Action     string
}

func (*Context) JSON

func (c *Context) JSON(data interface{}, status ...int) error

func (*Context) JSONError added in v0.9.1

func (c *Context) JSONError(err error, status ...int) error

type Controller

type Controller struct {
	*Utils
	Services map[string]ServiceInterface
	// contains filtered or unexported fields
}

func (*Controller) Init added in v0.3.3

func (c *Controller) Init(u *Utils, s map[string]ServiceInterface)

func (*Controller) OnInit added in v0.3.3

func (c *Controller) OnInit(callback func())

type ControllerInterface

type ControllerInterface interface {
	Init(u *Utils, s map[string]ServiceInterface)
}

type Controllers

type Controllers []interface{}

type DB added in v0.4.5

type DB struct {
	*gorm.DB
	Connector  Connector
	Migrations Migrations
}

type Database added in v0.3.4

type Database struct {
	Connector  Connector
	Migrations Migrations
}

type DatabaseConfig added in v0.6.0

type DatabaseConfig struct {
	Type     string
	Host     string
	Port     int
	Username string
	Password string
	Name     string
}

type Error added in v0.9.1

type Error struct {
	Code        int    `json:"code"`
	Message     string `json:"message"`
	Description string `json:"description,omitempty"`
}

func NewError added in v0.9.1

func NewError(code int, descriptions ...string) *Error

func NewErrorBadGateway added in v0.9.1

func NewErrorBadGateway(descriptions ...string) *Error

func NewErrorBadRequest added in v0.9.1

func NewErrorBadRequest(descriptions ...string) *Error

4xx

func NewErrorConflict added in v0.9.1

func NewErrorConflict(descriptions ...string) *Error

func NewErrorExpectationFailed added in v0.9.1

func NewErrorExpectationFailed(descriptions ...string) *Error

func NewErrorFailedDependency added in v0.9.1

func NewErrorFailedDependency(descriptions ...string) *Error

func NewErrorForbidden added in v0.9.1

func NewErrorForbidden(descriptions ...string) *Error

func NewErrorGatewayTimeout added in v0.9.1

func NewErrorGatewayTimeout(descriptions ...string) *Error

func NewErrorGone added in v0.9.1

func NewErrorGone(descriptions ...string) *Error

func NewErrorHTTPVersionNotSupported added in v0.9.1

func NewErrorHTTPVersionNotSupported(descriptions ...string) *Error

func NewErrorInsufficientStorage added in v0.9.1

func NewErrorInsufficientStorage(descriptions ...string) *Error

func NewErrorInternal added in v0.9.1

func NewErrorInternal(descriptions ...string) *Error

5xx

func NewErrorLengthRequired added in v0.9.1

func NewErrorLengthRequired(descriptions ...string) *Error

func NewErrorLocked added in v0.9.1

func NewErrorLocked(descriptions ...string) *Error

func NewErrorLoopDetected added in v0.9.1

func NewErrorLoopDetected(descriptions ...string) *Error

func NewErrorMethodNotAllowed added in v0.9.1

func NewErrorMethodNotAllowed(descriptions ...string) *Error

func NewErrorMisdirectedRequest added in v0.9.1

func NewErrorMisdirectedRequest(descriptions ...string) *Error

func NewErrorNetworkAuthenticationRequired added in v0.9.1

func NewErrorNetworkAuthenticationRequired(descriptions ...string) *Error

func NewErrorNotAcceptable added in v0.9.1

func NewErrorNotAcceptable(descriptions ...string) *Error

func NewErrorNotExtended added in v0.9.1

func NewErrorNotExtended(descriptions ...string) *Error

func NewErrorNotFound added in v0.9.1

func NewErrorNotFound(descriptions ...string) *Error

func NewErrorNotImplemented added in v0.9.1

func NewErrorNotImplemented(descriptions ...string) *Error

func NewErrorPaymentRequired added in v0.9.1

func NewErrorPaymentRequired(descriptions ...string) *Error

func NewErrorPreconditionFailed added in v0.9.1

func NewErrorPreconditionFailed(descriptions ...string) *Error

func NewErrorPreconditionRequired added in v0.9.1

func NewErrorPreconditionRequired(descriptions ...string) *Error

func NewErrorProxyAuthRequired added in v0.9.1

func NewErrorProxyAuthRequired(descriptions ...string) *Error

func NewErrorRequestEntityTooLarge added in v0.9.1

func NewErrorRequestEntityTooLarge(descriptions ...string) *Error

func NewErrorRequestHeaderFieldsTooLarge added in v0.9.1

func NewErrorRequestHeaderFieldsTooLarge(descriptions ...string) *Error

func NewErrorRequestTimeout added in v0.9.1

func NewErrorRequestTimeout(descriptions ...string) *Error

func NewErrorRequestURITooLong added in v0.9.1

func NewErrorRequestURITooLong(descriptions ...string) *Error

func NewErrorRequestedRangeNotSatisfiable added in v0.9.1

func NewErrorRequestedRangeNotSatisfiable(descriptions ...string) *Error

func NewErrorServiceUnavailable added in v0.9.1

func NewErrorServiceUnavailable(descriptions ...string) *Error

func NewErrorTeapot added in v0.9.1

func NewErrorTeapot(descriptions ...string) *Error

func NewErrorTooEarly added in v0.9.1

func NewErrorTooEarly(descriptions ...string) *Error

func NewErrorTooManyRequests added in v0.9.1

func NewErrorTooManyRequests(descriptions ...string) *Error

func NewErrorUnauthorized added in v0.9.1

func NewErrorUnauthorized(descriptions ...string) *Error

func NewErrorUnavailableForLegalReasons added in v0.9.1

func NewErrorUnavailableForLegalReasons(descriptions ...string) *Error

func NewErrorUnprocessableEntity added in v0.9.1

func NewErrorUnprocessableEntity(descriptions ...string) *Error

func NewErrorUnsupportedMediaType added in v0.9.1

func NewErrorUnsupportedMediaType(descriptions ...string) *Error

func NewErrorUpgradeRequired added in v0.9.1

func NewErrorUpgradeRequired(descriptions ...string) *Error

func NewErrorVariantAlsoNegotiates added in v0.9.1

func NewErrorVariantAlsoNegotiates(descriptions ...string) *Error

func (*Error) Error added in v0.9.1

func (e *Error) Error() string

type GeneralConfig added in v0.6.0

type GeneralConfig struct {
	Development bool
}

type Map

type Map map[string]interface{}

type Middleware

type Middleware struct {
	Utils *Utils
	// contains filtered or unexported fields
}

func (*Middleware) Init added in v0.3.3

func (m *Middleware) Init(u *Utils)

func (*Middleware) OnInit added in v0.3.3

func (m *Middleware) OnInit(callback func())

type MiddlewareInterface

type MiddlewareInterface interface {
	Init(u *Utils)
	New(*Context) error
}

type Middlewares

type Middlewares []MiddlewareInterface

type Migration added in v0.4.5

type Migration func(*DB) error

type Migrations added in v0.4.5

type Migrations map[int]Migration

type Model

type Model gorm.Model

type Raptor

type Raptor struct {
	Utils *Utils
	// contains filtered or unexported fields
}

func NewRaptor

func NewRaptor() *Raptor

func (*Raptor) Init

func (r *Raptor) Init(app *AppInitializer)

func (*Raptor) Listen

func (r *Raptor) Listen()

func (*Raptor) RegisterRoutes added in v0.8.3

func (r *Raptor) RegisterRoutes(routes Routes)

type Routes

type Routes []route

func CollectRoutes

func CollectRoutes(r ...Routes) Routes

func Route

func Route(method, path, controller, action string) Routes

func Scope

func Scope(path string, routes ...Routes) Routes

type SchemaMigration added in v0.4.5

type SchemaMigration struct {
	gorm.Model
	Version    string
	MigratedAt time.Time
}

type ServerConfig added in v0.6.0

type ServerConfig struct {
	Address         string
	Port            int
	ShutdownTimeout int
	ProxyHeader     string
}

type Service

type Service struct {
	*Utils
	// contains filtered or unexported fields
}

func (*Service) Init added in v0.3.3

func (s *Service) Init(u *Utils)

func (*Service) OnInit added in v0.3.3

func (s *Service) OnInit(callback func())

type ServiceInterface

type ServiceInterface interface {
	Init(u *Utils)
}

type Services

type Services []ServiceInterface

type StaticConfig added in v0.6.0

type StaticConfig struct {
	Enabled bool
	Prefix  string
	Root    string
}

type Template added in v0.7.0

type Template struct {
	Engine fiber.Views
	Layout string
}

type TemplatingConfig added in v0.6.0

type TemplatingConfig struct {
	Enabled bool
}

type Utils

type Utils struct {
	Config *Config
	Log    *slog.Logger
	DB     *DB
}

func (*Utils) SetConfig added in v0.4.12

func (u *Utils) SetConfig(config *Config)

func (*Utils) SetDB added in v0.4.0

func (u *Utils) SetDB(db *DB)

Jump to

Keyboard shortcuts

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