server

package
v2.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2021 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	DefaultQueryPage = 1
	DefaultQuerySize = 20
	MaxQuerySize     = 100
)

Variables

View Source
var DefaultErrorHandler = func(c *fiber.Ctx, err error) error {
	code := fiber.StatusInternalServerError
	if e, ok := err.(*fiber.Error); ok {
		code = e.Code
	}
	c.Set(fiber.HeaderContentType, fiber.MIMEApplicationJSON)
	return c.Status(code).JSON(fiber.Map{"error": err.Error()})
}

DefaultErrorHandler that process return errors from handlers

View Source
var DefaultFiberConfig = fiber.Config{
	Prefork:               util.GetEnv("HTTP_PRE_FORK", "true") == "true",
	ServerHeader:          util.GetEnv("HTTP_SERVER_HEADER", "GoFiber"),
	ProxyHeader:           util.GetEnv("HTTP_PROXY_HEADER", httputil.HeaderXForwardedFor),
	ReduceMemoryUsage:     util.GetEnv("HTTP_REDUCE_MEMORY_USAGE", "true") == "true",
	DisableStartupMessage: util.GetEnv("HTTP_DISABLE_STARTUP_MESSAGE", "true") == "true",
}

DefaultFiberConfig that use for standard fiber configuration

View Source
var DefaultServerAccessLog = func(lvl logrus.Level) fiber.Handler {
	logOut := logrus.New()
	logOut.SetLevel(lvl)
	return logger.New(logger.Config{
		Format:     "${time} ${method} ${path} - ${ip} - ${status} - ${latency}\n",
		TimeZone:   "Asia/Bangkok",
		TimeFormat: time.ANSIC,
		Output:     logOut.WriterLevel(lvl),
	})
}

DefaultServerAccessLog that use for enable fiber log to specific router

Functions

func ApplyStaticRoute

func ApplyStaticRoute(s *fiber.App, publicDir string)

ApplyStaticRoute that use for serve angular built

func NoCache

func NoCache(h http.Handler) http.Handler

Types

type Config

type Config struct {
	Host string
	Port string
	// Fiber Config
	Config *fiber.Config
}

type Pagination

type Pagination struct {
	Page int
	Size int
}

func GetPagination

func GetPagination(ctx *fiber.Ctx) Pagination

func (*Pagination) Offset

func (p *Pagination) Offset() int

type Result

type Result struct {
	Error   interface{} `json:"error,omitempty"`
	Message interface{} `json:"msg,omitempty"`
	Data    interface{} `json:"data,omitempty"`
	Total   int         `json:"total,omitempty"`
	Count   int         `json:"count,omitempty"`
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func New

func New(config Config) Server

func (*Server) App

func (s *Server) App() *fiber.App

func (*Server) Run

func (s *Server) Run() error

type SkipperPath

type SkipperPath struct {
	Prefix string
	Paths  map[string]bool
}

func NewSkipperPath

func NewSkipperPath(prefix string) SkipperPath

func (*SkipperPath) Add

func (s *SkipperPath) Add(path string, method string)

func (*SkipperPath) Delete

func (s *SkipperPath) Delete(path string, method string)

func (*SkipperPath) Test

func (s *SkipperPath) Test(ctx *fiber.Ctx) bool

Jump to

Keyboard shortcuts

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