fastic

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 15 Imported by: 0

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

View Source
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

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 New

func New() *App

this function maded for create new application model =D

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

func (a *App) Group(path string) *router.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) Print

func (a *App) Print(clr, model, message string)

the print function, maded for print your string on terminal =D

func (*App) PrintB

func (a *App) PrintB(clr, model string, message []byte)

printb method, this method get's byte.

func (*App) Run

func (app *App) Run(h fasthttp.RequestHandler)

a function for run server. and show default run server message to user.

func (*App) Static

func (a *App) Static(prefix, root string)

static router method maded for serve html,css ... files. u can use application.Static or application.Router.ServeFiles

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

func (c *Ctx) Attachment(path string) error

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) Bind added in v1.1.0

func (c *Ctx) Bind(v interface{}) error

Bind method maded for get json from request body (for rest api)

func (*Ctx) Body

func (c *Ctx) Body() []byte

this method maded for show you a request body =D

func (*Ctx) Delete added in v1.2.0

func (c *Ctx) Delete(url string) ([]byte, error)

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) FormValue

func (c *Ctx) FormValue(key string) string

FormValue method maded for show POST method value's

func (*Ctx) Get added in v1.2.0

func (c *Ctx) Get(url string) ([]byte, error)

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

func (c *Ctx) JSON(data interface{}) error

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

func (c *Ctx) Options(url string) ([]byte, error)

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

func (c *Ctx) Param(key string) string

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

func (c *Ctx) Post(url string, body []byte) ([]byte, error)

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

func (c *Ctx) PostJSON(url string, body []byte, v interface{}) error

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

func (c *Ctx) Put(url string, body []byte) ([]byte, error)

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

func (c *Ctx) Query(key string) string

this method maded for show paramter querys, example of querys: /example?name=value.

func (*Ctx) RawJSON

func (c *Ctx) RawJSON(rawJSON string)

RawJSON method helps you on write json response example: `{"message": "pong"}` this is easy and don't need to maps.

func (*Ctx) Status

func (c *Ctx) Status(status int) *Ctx

Status method maded for change status code of ctx and return new ctx to user

func (*Ctx) String

func (c *Ctx) String(s string)

this method maded for show your message as text/plain model, if your website content type is application/json this method changes to text/plain and show's raw message on website.

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

func LoadEnv added in v1.1.0

func LoadEnv() *Env

this function maded for read and load env files and save env values to Env struct.

func (*Env) Create added in v1.1.0

func (e *Env) Create() (ok bool)

this method maded for create ".env" file on your project, this method make's new ".env" file with default settings on caller function path. (call this function on main.go)

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
}

func MdwNew

func MdwNew() *Mdw

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.

Jump to

Keyboard shortcuts

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