api

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: MIT Imports: 11 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggerMiddleware

func LoggerMiddleware(r *mux.Router) mux.MiddlewareFunc

Log each HTTP request with its execution time and request_id

func NewStatusResponseWriter

func NewStatusResponseWriter(w http.ResponseWriter) *statusResponseWriter

func RequestIDLoggerMiddleware

func RequestIDLoggerMiddleware(r *mux.Router) mux.MiddlewareFunc

Generate (if there is none) and store request_id both in the request context AND X-REQUEST-ID header

func URLSchemaMiddleware

func URLSchemaMiddleware(r *mux.Router) mux.MiddlewareFunc

Types

type API

type API struct {
	HttpListenPort int
	// contains filtered or unexported fields
}

func New

func New(port int, db storage.Storage) *API

func (*API) Run

func (api *API) Run(ctx context.Context) error

type PaginatedResponse

type PaginatedResponse struct {
	Articles  []storage.ArticleShort `json:"articles"`
	Paginator Paginator              `json:"paginator"`
}

type Paginator

type Paginator struct {
	NumPages int `json:"num_pages"`
	CurPage  int `json:"cur_page"`
	PageSize int `json:"page_size"`
}

Jump to

Keyboard shortcuts

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