Documentation
¶
Overview ¶
▲ PLEASE DONT CHANGE THIS CODE THIS IS A DEFAULT APP CODE, CHANGEING THIS CODE CAN BROKE YOUR SITE.
▲ PLEASE DONT CHANGE THIS CODE THIS IS A DEFAULT APP CODE, CHANGEING THIS CODE CAN BROKE YOUR SITE.
▲ PLEASE DONT CHANGE THIS CODE THIS IS A DEFAULT APP CODE, CHANGEING THIS CODE CAN BROKE YOUR SITE.
▲ PLEASE DONT CHANGE THIS CODE THIS IS A DEFAULT APP CODE, CHANGEING THIS CODE CAN BROKE YOUR SITE.
▲ THIS FILE CODES THEY ARE ONLY EXAMPLE, THEY ARE NOT GOOD FOR REAL USE! PLEASE DONT USE THIS MIDDLEWARES FOR REAL PROJECT
▲ PLEASE DONT CHANGE THIS CODE THIS IS A DEFAULT APP CODE, CHANGEING THIS CODE CAN BROKE YOUR SITE.
▲ PLEASE DONT CHANGE THIS CODE THIS IS A DEFAULT APP CODE, CHANGEING THIS CODE CAN BROKE YOUR SITE.
Index ¶
- Constants
- func ChainMdw(handler fasthttp.RequestHandler, ...) fasthttp.RequestHandler
- type App
- func (a *App) DELETE(path string, handler RequestHandler, ...)
- func (a *App) GET(path string, handler RequestHandler, ...)
- func (a *App) Group(path string) *router.Group
- func (a *App) OPTIONS(path string, handler RequestHandler, ...)
- func (a *App) POST(path string, handler RequestHandler, ...)
- func (a *App) PUT(path string, handler RequestHandler, ...)
- func (a *App) Print(clr, model, message string)
- func (a *App) PrintB(clr, model string, message []byte)
- func (app *App) Run(h fasthttp.RequestHandler)
- func (a *App) Static(prefix, root string)
- type Ctx
- func (c *Ctx) Attachment(path string) error
- func (c *Ctx) Bind(v interface{}) error
- func (c *Ctx) Body() []byte
- func (c *Ctx) Delete(url string) ([]byte, error)
- func (c *Ctx) Fetch(url string, opts ...FetchOptions) ([]byte, error)
- func (c *Ctx) FetchJSON(url string, v interface{}, opts ...FetchOptions) error
- func (c *Ctx) FormValue(key string) string
- func (c *Ctx) Get(url string) ([]byte, error)
- func (c *Ctx) JSON(data interface{}) error
- func (c *Ctx) Options(url string) ([]byte, error)
- func (c *Ctx) Param(key string) string
- func (c *Ctx) Post(url string, body []byte) ([]byte, error)
- func (c *Ctx) PostJSON(url string, body []byte, v interface{}) error
- func (c *Ctx) Put(url string, body []byte) ([]byte, error)
- func (c *Ctx) Query(key string) string
- func (c *Ctx) RawJSON(rawJSON string)
- func (c *Ctx) Status(status int) *Ctx
- func (c *Ctx) String(s string)
- type Env
- type FetchOptions
- type Mdw
- type RequestHandler
Constants ¶
const ( // this is application version (only for display), // [WARNING] dont change this. Version = "v1.0" FetchTimeout = 10 * time.Second // this value is default ".env" file contents =D EnvFileContent = `` /* 4037-byte string literal not displayed */ )
default values, for see to all user's
Variables ¶
This section is empty.
Functions ¶
func ChainMdw ¶
func ChainMdw(handler fasthttp.RequestHandler, middlewares ...func(fasthttp.RequestHandler) fasthttp.RequestHandler) fasthttp.RequestHandler
this function maded for run multiplate middleware's. (use on main.go) # only for main middlewares
Types ¶
type App ¶
type App struct {
// router of fasthttp (if user need to other methods)
Router *router.Router
// handler for fasthttp, need this for run server. and load middlewares. =D
Handler fasthttp.RequestHandler
// router for env values (cache for speed responses)
Env *Env
// mdw for load chain middlewares and more =D
Mdw *Mdw
}
app structure example, you can add router and templates section!
func (*App) DELETE ¶
func (a *App) DELETE(path string, handler RequestHandler, middlewares ...func(RequestHandler) RequestHandler)
DELETE method example, you can use application.DELETE or application.Router.DELETE on your code.
func (*App) GET ¶
func (a *App) GET(path string, handler RequestHandler, middlewares ...func(RequestHandler) RequestHandler)
= - = - = - = - = - = - = - = - Request Methods = - = - = - = - = - = - = - = - [TIPS] if you need speed web application you can use application.Router.GET, if you need easy coding use application.GET =D GET method example, you can use application.GET or application.Router.GET on your code. [UPDATE] updated methods model with ctx because added cutsom ctx for requests
func (*App) Group ¶
= - = - = - = - = - = - = - = - Other Methods = - = - = - = - = - = - = - = - router group for creating groups and use custom middlewares for groups. u can use application.Router.Group() or application.Group()
func (*App) OPTIONS ¶
func (a *App) OPTIONS(path string, handler RequestHandler, middlewares ...func(RequestHandler) RequestHandler)
OPTIONS method example, you can use application.OPTIONS or application.Router.OPTIONS on your code.
func (*App) POST ¶
func (a *App) POST(path string, handler RequestHandler, middlewares ...func(RequestHandler) RequestHandler)
POST method example, you can use application.POST or application.Router.POST on your code.
func (*App) PUT ¶
func (a *App) PUT(path string, handler RequestHandler, middlewares ...func(RequestHandler) RequestHandler)
PUT method example, you can use application.PUT or application.Router.PUT on your code.
func (*App) Run ¶
func (app *App) Run(h fasthttp.RequestHandler)
a function for run server. and show default run server message to user.
type Ctx ¶
type Ctx struct {
*fasthttp.RequestCtx
}
create new structure named Ctx for create custom request ctx only for requests for fastic framework
func (*Ctx) Attachment ¶ added in v1.1.0
Attachment method, you can add your file path for download. if user enter to this addres your uploaded file path starting to download.
func (*Ctx) Delete ¶ added in v1.2.0
this method maded for fetch requests with delete method. u can use c.Fetch for use custom method's and settings =D
func (*Ctx) Fetch ¶ added in v1.2.0
func (c *Ctx) Fetch(url string, opts ...FetchOptions) ([]byte, error)
fetch method send's request to target url, you can edit options with fastic.FetchOptions struct, if you need use default templates you can use "c.Get", "c.Post" and... methods for fetch
func (*Ctx) FetchJSON ¶ added in v1.2.0
func (c *Ctx) FetchJSON(url string, v interface{}, opts ...FetchOptions) error
fetch json method help's you for get response as json and save your json response on your struct.
func (*Ctx) Get ¶ added in v1.2.0
this method maded for fetch requests with get method. u can use c.Fetch for use custom method's and settings =D
func (*Ctx) JSON ¶
this method maded for show your message as json message, chnages content website type to application/json
func (*Ctx) Options ¶ added in v1.2.0
this method maded for fetch requests with options method. u can use c.Fetch for use custom method's and settings =D
func (*Ctx) Param ¶
this method is for use ctx paramter easy, UserValue is too hard for daily use they are created easy method named Param
func (*Ctx) Post ¶ added in v1.2.0
this method maded for fetch requests with post method. u can use c.Fetch for use custom method's and settings =D
func (*Ctx) PostJSON ¶ added in v1.2.0
this method maded for fetch requests with post (have json body) method. u can use c.Fetch for use custom method's and settings =D
func (*Ctx) Put ¶ added in v1.2.0
this method maded for fetch requests with put method. u can use c.Fetch for use custom method's and settings =D
func (*Ctx) Query ¶
this method maded for show paramter querys, example of querys: /example?name=value.
func (*Ctx) RawJSON ¶
RawJSON method helps you on write json response example: `{"message": "pong"}` this is easy and don't need to maps.
type Env ¶ added in v1.1.0
type Env struct {
// on this section will saves .env file find status. =D
LoadedFile bool
// global and general var's
DevelopemtMode bool
Port int // serv amd listen port
// this section is for website cors
AllowedDomains map[string]bool
IsWildcard bool
AllowedMethods string
AllowedHeaders string
MaxAge int
// security header's section
XFrameOptions string
ReferrerPolicy string
ContentSecurityPolicy string
StrictTransportSecurity string
// server settions values
MaxConnsPerIP int
MaxRequestBodySize int
IdleTimeout int // per seccond...
ReadTimeout int // per seccond...
WriteTimeout int // per seccond...
Concurrency int
DisableKeepalive bool
}
env file load structure =D
type FetchOptions ¶ added in v1.2.0
type FetchOptions struct {
Method string // method of request = example: GET,POST
Headers map[string]string // request headers
Body []byte
Timeout time.Duration // timeout of request
}
create new struct type for fetch settings =D
type Mdw ¶
type Mdw struct {
SChain func(handler fasthttp.RequestHandler, middlewares ...func(fasthttp.RequestHandler) fasthttp.RequestHandler) fasthttp.RequestHandler
Chain func(handler RequestHandler, middlewares ...func(RequestHandler) RequestHandler) RequestHandler
}
type RequestHandler ¶
type RequestHandler func(*Ctx)
handler function for fastic.
func ChainCtx ¶
func ChainCtx(handler RequestHandler, middlewares ...func(RequestHandler) RequestHandler) RequestHandler
this method maded for run other middlewares.