fhserver

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2022 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContentTypeJSON = []byte("application/json")
	ContentTypeText = []byte("text/plain; charset=utf-8")
)
View Source
var (
	CommonValidationErrors = map[string]validationErrors{
		"ru": {
			"ek":       "Ошибка валидации для свойства `%s` с правилом `%s`",
			"required": "Свойство `%s` обязательно для заполнения",
			"gt":       "Свойство `%s` должно содержать более `%s` элементов",
		},
	}
)

Functions

func AuthorizationHeader

func AuthorizationHeader(ctx *fasthttp.RequestCtx) (payload []byte, exist bool)

func BasicAuth

func BasicAuth(payload []byte) (user, pass []byte, exist bool)

BasicAuth returns the username and password provided in the request's Authorization header, if the request uses HTTP Basic Authentication. See RFC 2617, Section 2.

func JSON

func JSON(ctx *fasthttp.RequestCtx, response interface{})

JSON makes common response in json.

Types

type Response

type Response struct {
	Error *errs.ErrorObject `json:"error,omitempty"`
	Data  interface{}       `json:"data,omitempty"`
}

type Server

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

func New

func New(config contracts.WebServerInterface) *Server

New creates a new WebServer Server.

func (*Server) Run

func (s *Server) Run(wg *sync.WaitGroup)

Run starts the HTTP server and performs a graceful shutdown.

func (*Server) SetLogger

func (s *Server) SetLogger(logger log.Logger) *Server

func (*Server) SetRouter

func (s *Server) SetRouter(r *router.Router)

Jump to

Keyboard shortcuts

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