restx

package
v0.0.0-...-f15602e Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package restx contains utils for rest handlers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIDFromURLParams

func GetIDFromURLParams(r *http.Request, paramName string) (int64, error)

GetIDFromURLParams return id as an int64 from get params by its name.

func GetPaginationParams

func GetPaginationParams(r *http.Request) (*paging.Pagination, error)

GetPaginationParams parses request pagination parameters.

func HandleError

func HandleError(w http.ResponseWriter, r *http.Request, err error)

HandleError return in response the rendered error.

Types

type ErrorResponse

type ErrorResponse struct {
	HTTPStatusCode int    `json:"-"`
	Message        string `json:"message"`
}

ErrorResponse is error struct for response.

func (ErrorResponse) Render

Render http error response.

Jump to

Keyboard shortcuts

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