http

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserLocalsKey    = "user"
	ErrNotFoundInCtx = "user not found in context"
)

Variables

View Source
var (
	ErrStartTimeout = errors.New("start http server timeout")
)

Functions

func ErrorsMiddleware

func ErrorsMiddleware(
	logger zerolog.Logger,
	ipHeader string,
	getUserFromCtxFunc func(c *fiber.Ctx) any,
	secureReqJsonPaths []string,
	secureResJsonPaths []string,
	showInternalErrorsInResponse bool,
) fiber.Handler

func TraceMiddleware

func TraceMiddleware() fiber.Handler

Types

type Binder

type Binder interface {
	BindRoutes(ctx context.Context)
}

type Config

type Config struct {
	Cors    Cors    `validate:"required"`
	Serve   Serve   `validate:"required"`
	Logging Logging `validate:"required"`
}

type Cors

type Cors struct {
	AllowOrigins     string `validate:"required"`
	AllowHeaders     string `validate:"required"`
	ExposeHeaders    string `validate:"required"`
	AllowCredentials bool
}

type FiberServer

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

func NewWithBinder

func NewWithBinder(
	cfg Config,
	server *Server,
	binder Binder,
	registry prometheus.Registerer,
) *FiberServer

func (*FiberServer) Start

func (f *FiberServer) Start(_ context.Context) (err error)

func (*FiberServer) Stop

func (f *FiberServer) Stop(_ context.Context) (err error)

type Logging

type Logging struct {
	SecureReqJsonPaths          []string
	SecureResJsonPaths          []string
	ShowUnknownErrorsInResponse bool
}

type LoggingData

type LoggingData struct {
	TraceID      string `json:"traceID"`
	RemoteIP     string `json:"remoteIP"`
	Host         string `json:"host"`
	Method       string `json:"method"`
	Path         string `json:"path"`
	Protocol     string `json:"protocol"`
	RequestBody  string `json:"requestBody"`
	ResponseBody string `json:"responseBody"`
	StatusCode   int    `json:"statusCode"`
	Latency      int64  `json:"latency"`
	User         any    `json:"user"`
	Error        string `json:"error"`
	Stack        []byte `json:"stack"`
}

func (*LoggingData) MarshalZerologObject

func (d *LoggingData) MarshalZerologObject(e *zerolog.Event)

type Serve

type Serve struct {
	Host                  string `validate:"required" default:"127.0.0.1"`
	IpHeader              string `validate:"required" default:"X-Real-IP"`
	BodyLimit             int
	StopTimeout           duration.Seconds `default:"10"`
	DisableStartupMessage bool
}

type Server

type Server struct {
	*fiber.App
}

func New

func New(cfg Serve) *Server

type User

type User struct {
	ID            int64  `json:"id"`
	Login         string `json:"login"`
	FirstName     string `json:"first_name"`
	SecondName    string `json:"last_name"`
	Role          string `json:"role"`
	PermissionKey int64
}

type UserNotFoundErr

type UserNotFoundErr struct {
	Msg string `json:"msg"`
}

Jump to

Keyboard shortcuts

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