webserver

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ReadBufferSize = 8192

Variables

View Source
var ErrInternal = errors.New("internal error")
View Source
var ErrorHandler = func(c *fiber.Ctx, err error) error {
	return c.Status(http.StatusInternalServerError).JSON(Response{
		Ok: false,
		Error: &ErrorResponse{
			Message: err.Error(),
			Code:    0,
		},
	})
}

Functions

func NewFiberApp

func NewFiberApp(name string) *fiber.App

Types

type Chain

type Chain func(h fiber.Handler) fiber.Handler

Chain single sequence

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
	Code    int    `json:"code"`
}

func (ErrorResponse) MarshalEasyJSON

func (v ErrorResponse) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ErrorResponse) MarshalJSON

func (v ErrorResponse) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ErrorResponse) UnmarshalEasyJSON

func (v *ErrorResponse) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ErrorResponse) UnmarshalJSON

func (v *ErrorResponse) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

type Middleware

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

Middleware contains methods to call before handle request

func NewMiddleware

func NewMiddleware(c ...Chain) *Middleware

NewMiddleware return new natsmiddleware

func (*Middleware) AddChain

func (m *Middleware) AddChain(c Chain)

AddChain add natsmiddleware to execute

func (*Middleware) Copy

func (m *Middleware) Copy() *Middleware

Copy return copied sequence

func (*Middleware) Merge

func (m *Middleware) Merge(middlewares ...*Middleware)

Merge merge logmiddlewares into current

func (*Middleware) Then

func (m *Middleware) Then(h fiber.Handler) fiber.Handler

Then return router handler

type Pagination

type Pagination struct {
	Total   int `json:"total"`
	Page    int `json:"page"`
	Pages   int `json:"pages"`
	PerPage int `json:"per_page"`
}

func (Pagination) MarshalEasyJSON

func (v Pagination) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Pagination) MarshalJSON

func (v Pagination) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Pagination) UnmarshalEasyJSON

func (v *Pagination) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Pagination) UnmarshalJSON

func (v *Pagination) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Response

type Response struct {
	Data       interface{}    `json:"data,omitempty"`
	Error      *ErrorResponse `json:"error,omitempty"`
	Pagination *Pagination    `json:"pagination,omitempty"`
	Ok         bool           `json:"ok"`
}

func GetResponseWithError

func GetResponseWithError(err error, code int) *Response

func GetSuccessResponse

func GetSuccessResponse(data interface{}) *Response

func GetSuccessResponseList

func GetSuccessResponseList(data interface{}, total, page, perPage int) *Response

func (Response) MarshalEasyJSON

func (v Response) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Response) MarshalJSON

func (v Response) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Response) UnmarshalEasyJSON

func (v *Response) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Response) UnmarshalJSON

func (v *Response) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

Directories

Path Synopsis
Package mock_webserver is a generated GoMock package.
Package mock_webserver is a generated GoMock package.

Jump to

Keyboard shortcuts

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