Documentation ¶
Index ¶
- Variables
- func AdminOnly(ctx *Context) error
- func BasicAuth(ctx *Context) error
- func BasicHeaders(ctx *Context) error
- func EmptyJson() map[string]interface{}
- func HandleResponseJSON(ctx *Context, body []byte, status int) error
- func HeaderFromCtx(ctx *Context, key string) string
- func Limiter(ctx *Context) error
- func LogRequest(ctx *Context) error
- func MethodNotAllowed(ctx *Context) error
- func NextRequestID() string
- func NotFoundServer(ctx *Context) error
- func ResponseJson(ctx *Context, output string, status int, error string) error
- func Status(ctx *Context) error
- func TeaPot(ctx *Context) error
- type Application
- type Communication
- type Components
- type Config
- type Context
- type Emailer
- type Environment
- type Handler
- type Log
- type Middleware
- type Persistence
- type Res
- type Response
- type ResponseConfig
- type Router
- func (r *Router) Delete(uri string, handler routing.Handler)
- func (r *Router) Get(uri string, handler routing.Handler)
- func (r *Router) New(uri string, handler routing.Handler, methods []string, ...)
- func (r *Router) Post(uri string, handler routing.Handler)
- func (r *Router) Put(uri string, handler routing.Handler)
- type Server
Constants ¶
This section is empty.
Variables ¶
View Source
var ( MethodGet = []string{"GET"} MethodPut = []string{"PUT"} MethodPost = []string{"POST"} MethodDelete = []string{"DELETE"} )
View Source
var EnvironmentVariableName = "SPK_ENV"
View Source
var Version = "1.3.8"
Functions ¶
func BasicHeaders ¶
BasicHeaders applies our general headers. Forced middleware
func HandleResponseJSON ¶
HandleResponseJSON handles general responses via JSON.
func HeaderFromCtx ¶
HeaderFromCtx returns the requested header from the given fasthttp context
func MethodNotAllowed ¶
func NextRequestID ¶
func NextRequestID() string
NextRequestID returns the next request id, which is a unix timestamp.
func NotFoundServer ¶
NotFoundServer is the default 404 handler
func ResponseJson ¶ added in v1.3.6
ResponseJson creates a body and returns a JSON response
Types ¶
type Application ¶
type Communication ¶
type Communication struct {
Email Emailer `json:"email"`
}
type Components ¶
type Components struct { BigCache bool `json:"bigCache,omitempty"` MemCache bool `json:"memCache,omitempty"` Memory bool `json:"memory,omitempty"` Redis bool `json:"redis,omitempty"` MySQL bool `json:"mysql,omitempty"` HTTPCache bool `json:"HTTPCache,omitempty"` Log bool `json:"log,omitempty"` StatsView bool `json:"stats_view"` }
type Config ¶
type Config struct { Application `json:"application"` Components `json:"components"` Server `json:"server"` Middleware `json:"middleware"` Router `json:"router"` Log `json:"log"` Environment `json:"environment"` Persistence `json:"persistence"` Communication `json:"communication"` S mantis.Status }
var App *Config
func New ¶
func New() *Config
New creates a new App based on Config. It Loads() the config file based on the ENV that is set, then calls Factory() to stand up our application.
func (*Config) Factory ¶
func (c *Config) Factory()
Factory creates our Application and instantiates our services
type Environment ¶
type Middleware ¶ added in v1.3.8
type Middleware struct { Limiter struct { Enabled bool `json:"enabled"` Time int `json:"time"` Max int `json:"max"` } `json:"limiter"` LogRequest struct { Enabled bool `json:"enabled"` } `json:"log_request"` BasicHeaders struct { Enabled bool `json:"enabled"` ShowServer bool `json:"show_server"` } `json:"basic_headers"` AdminOnly struct { Enabled bool `json:"enabled"` } `json:"admin_only"` BasicAuth struct { Enabled bool `json:"enabled"` } `json:"basic_auth"` }
type Persistence ¶
type Persistence struct { BigCache mantisCache.BigCache `json:"bigCache"` MemCache mantisCache.MemCache `json:"memCache"` Memory *mantisCache.Memory `json:"memory"` Redis mantisDatabase.Redis `json:"redis"` MySQL mantisDatabase.MySQL `json:"mysql"` Neo4j mantisDatabase.Neo4j `json:"neo4J"` }
type ResponseConfig ¶ added in v1.3.8
type Router ¶
type Router struct { Routes []route `json:"routes,omitempty"` Router *routing.Router // contains filtered or unexported fields }
func (*Router) New ¶
func (r *Router) New(uri string, handler routing.Handler, methods []string, middlewares []routing.Handler)
New appends a new route to our route struct.
type Server ¶
type Server struct { Address string `json:"address,omitempty"` Port string `json:"port,omitempty"` WriteTimeout time.Duration `json:"writeTimeout,omitempty"` ReadTimeout time.Duration `json:"readTimeout,omitempty"` MemCacheTime time.Duration `json:"memCacheTime,omitempty"` ResponseConfig ResponseConfig `json:"response_config"` }
Click to show internal directories.
Click to hide internal directories.