rest

package
v0.0.0-...-07f3eb5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FilterParamType = "type"
	SortParam       = "time_spent"
)
View Source
const (
	PaginationParamPage  = "page"
	PaginationParamLimit = "limit"
	DefaultPage          = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrWithHint

type ErrWithHint struct {
	Code    int
	Message string
	Field   string
	Err     error
}

ErrWithHint custom error for ErrorHandler.

func ErrBadRequestInvalidParameter

func ErrBadRequestInvalidParameter(name string, description ...string) *ErrWithHint

func (ErrWithHint) Error

func (e ErrWithHint) Error() string

func (*ErrWithHint) WithErr

func (e *ErrWithHint) WithErr(err error) *ErrWithHint

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
	Field   string `json:"field,omitempty"`
}

ErrorResponse defines the body of an error response.

type FnGetter

type FnGetter func(key string, defaultValue ...string) string

type Handler

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

func NewHandler

func NewHandler(repo StatementsRepo, maxQueryDuration uint64) *Handler

func (*Handler) GetAll

func (h *Handler) GetAll(ctx *fiber.Ctx) error

GetAll returns all slow query in database

type Pagination

type Pagination struct {
	Page     int `json:"page"`
	PageSize int `json:"page_size"`
}

Pagination used for splitting large data into the small pieces

type Parser

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

func QueryParam

func QueryParam(s QueryGetter) *Parser

func (*Parser) SimplePagination

func (p *Parser) SimplePagination() (SimplePaginationParams, error)

SimplePagination returns SimplePaginationParams from source or parsing error.

func (*Parser) StringFromEnum

func (p *Parser) StringFromEnum(name string, enum []string) (string, error)

StringFromEnum get value by key from source and compare with enum values. if value in source is empty returns empty string.

type QueryGetter

type QueryGetter interface {
	Query(key string, defaultValue ...string) string
}

type ResponseWithPayload

type ResponseWithPayload struct {
	Message    string      `json:"message,omitempty"`
	Pagination Pagination  `json:"pagination,omitempty"`
	Payload    interface{} `json:"payload,omitempty"`
}

ResponseWithPayload common response with any data in Payload field.

type Server

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

Server represents API server of application

func (*Server) Run

func (s *Server) Run(addr string, h *Handler) error

Run creates configuration for the server and starts it

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown stops the Server

type SimplePaginationParams

type SimplePaginationParams struct {
	Page  int `json:"page"`
	Limit int `json:"limit"`
}

type StatementsRepo

type StatementsRepo interface {
	GetByType(maxExecTime uint64, qType string, timeSpent string, limit, offset int) ([]psql.PgStatStatement, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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