raptor

package module
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: MIT Imports: 18 Imported by: 0

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
	DefaultServerConfigShutdownTimeout = 3
	DefaultServerConfigProxyHeader     = ""

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

	DefaultTemplatingConfigEnabled = false

	DefaultStaticConfigEnabled = true
	DefaultStaticConfigPrefix  = "/public"
	DefaultStaticConfigRoot    = "./public"
	DefaultStaticConfigHTML5   = false
	DefaultStaticConfigIndex   = "index.html"
	DefaultStaticConfigBrowse  = false

	DefaultCORSConfigOrigins     = "*"
	DefaultCORSConfigCredentials = false
)
View Source
const (
	Version = "v3.0.1"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppInitializer

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

type CORSConfig

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

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

func (*Config) ApplyEnvirontmentVariables

func (c *Config) ApplyEnvirontmentVariables()

type Connector

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

type Context

type Context struct {
	echo.Context
	Controller string
	Action     string
}

func (*Context) JSON

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

func (*Context) JSONError

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

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

func (*Controller) OnInit

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

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

type Database

type Database struct {
	Connector  Connector
	Migrations Migrations
}

type DatabaseConfig

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

type Error

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

func NewError

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

func NewErrorBadGateway

func NewErrorBadGateway(descriptions ...string) *Error

func NewErrorBadRequest

func NewErrorBadRequest(descriptions ...string) *Error

4xx

func NewErrorConflict

func NewErrorConflict(descriptions ...string) *Error

func NewErrorExpectationFailed

func NewErrorExpectationFailed(descriptions ...string) *Error

func NewErrorFailedDependency

func NewErrorFailedDependency(descriptions ...string) *Error

func NewErrorForbidden

func NewErrorForbidden(descriptions ...string) *Error

func NewErrorGatewayTimeout

func NewErrorGatewayTimeout(descriptions ...string) *Error

func NewErrorGone

func NewErrorGone(descriptions ...string) *Error

func NewErrorHTTPVersionNotSupported

func NewErrorHTTPVersionNotSupported(descriptions ...string) *Error

func NewErrorInsufficientStorage

func NewErrorInsufficientStorage(descriptions ...string) *Error

func NewErrorInternal

func NewErrorInternal(descriptions ...string) *Error

5xx

func NewErrorLengthRequired

func NewErrorLengthRequired(descriptions ...string) *Error

func NewErrorLocked

func NewErrorLocked(descriptions ...string) *Error

func NewErrorLoopDetected

func NewErrorLoopDetected(descriptions ...string) *Error

func NewErrorMethodNotAllowed

func NewErrorMethodNotAllowed(descriptions ...string) *Error

func NewErrorMisdirectedRequest

func NewErrorMisdirectedRequest(descriptions ...string) *Error

func NewErrorNetworkAuthenticationRequired

func NewErrorNetworkAuthenticationRequired(descriptions ...string) *Error

func NewErrorNotAcceptable

func NewErrorNotAcceptable(descriptions ...string) *Error

func NewErrorNotExtended

func NewErrorNotExtended(descriptions ...string) *Error

func NewErrorNotFound

func NewErrorNotFound(descriptions ...string) *Error

func NewErrorNotImplemented

func NewErrorNotImplemented(descriptions ...string) *Error

func NewErrorPaymentRequired

func NewErrorPaymentRequired(descriptions ...string) *Error

func NewErrorPreconditionFailed

func NewErrorPreconditionFailed(descriptions ...string) *Error

func NewErrorPreconditionRequired

func NewErrorPreconditionRequired(descriptions ...string) *Error

func NewErrorProxyAuthRequired

func NewErrorProxyAuthRequired(descriptions ...string) *Error

func NewErrorRequestEntityTooLarge

func NewErrorRequestEntityTooLarge(descriptions ...string) *Error

func NewErrorRequestHeaderFieldsTooLarge

func NewErrorRequestHeaderFieldsTooLarge(descriptions ...string) *Error

func NewErrorRequestTimeout

func NewErrorRequestTimeout(descriptions ...string) *Error

func NewErrorRequestURITooLong

func NewErrorRequestURITooLong(descriptions ...string) *Error

func NewErrorRequestedRangeNotSatisfiable

func NewErrorRequestedRangeNotSatisfiable(descriptions ...string) *Error

func NewErrorServiceUnavailable

func NewErrorServiceUnavailable(descriptions ...string) *Error

func NewErrorTeapot

func NewErrorTeapot(descriptions ...string) *Error

func NewErrorTooEarly

func NewErrorTooEarly(descriptions ...string) *Error

func NewErrorTooManyRequests

func NewErrorTooManyRequests(descriptions ...string) *Error

func NewErrorUnauthorized

func NewErrorUnauthorized(descriptions ...string) *Error

func NewErrorUnavailableForLegalReasons

func NewErrorUnavailableForLegalReasons(descriptions ...string) *Error

func NewErrorUnprocessableEntity

func NewErrorUnprocessableEntity(descriptions ...string) *Error

func NewErrorUnsupportedMediaType

func NewErrorUnsupportedMediaType(descriptions ...string) *Error

func NewErrorUpgradeRequired

func NewErrorUpgradeRequired(descriptions ...string) *Error

func NewErrorVariantAlsoNegotiates

func NewErrorVariantAlsoNegotiates(descriptions ...string) *Error

func (*Error) Error

func (e *Error) Error() string

type GeneralConfig

type GeneralConfig struct {
	Development bool
}

type Map

type Map map[string]interface{}

type Middleware

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

func (*Middleware) InitMiddleware

func (m *Middleware) InitMiddleware(r *Raptor)

func (*Middleware) OnInit

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

type MiddlewareInterface

type MiddlewareInterface interface {
	InitMiddleware(r *Raptor)
	New(*Context) error
}

type Middlewares

type Middlewares []MiddlewareInterface

type Migration

type Migration func(*DB) error

type Migrations

type Migrations map[int]Migration

type Raptor

type Raptor struct {
	Utils  *Utils
	Server *echo.Echo

	Routes Routes
	// contains filtered or unexported fields
}

func NewRaptor

func NewRaptor() *Raptor

func (*Raptor) Init

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

func (*Raptor) Listen

func (r *Raptor) Listen()

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

func (*Routes) Path

func (r *Routes) Path(controller, action string) (string, error)

type SchemaMigration

type SchemaMigration struct {
	ID         int       `bun:"id,pk,autoincrement"`
	Version    string    `bun:"version,notnull"`
	MigratedAt time.Time `bun:"migrated_at,notnull"`
	CreatedAt  time.Time `bun:"created_at,notnull"`
	UpdatedAt  time.Time `bun:"updated_at,notnull"`
}

type ServerConfig

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

type Service

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

func (*Service) InitService

func (s *Service) InitService(r *Raptor)

func (*Service) OnInit

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

type ServiceInterface

type ServiceInterface interface {
	InitService(r *Raptor)
}

type Services

type Services []ServiceInterface

type StaticConfig

type StaticConfig struct {
	Enabled bool
	Prefix  string
	Root    string
	HTML5   bool
	Index   string
	Browse  bool
}

type Template

type Template struct {
	// Engine fiber.Views
	Layout string
}

type TemplatingConfig

type TemplatingConfig struct {
	Enabled bool
}

type Utils

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

func (*Utils) SetConfig

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

func (*Utils) SetDB

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

Jump to

Keyboard shortcuts

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