rest

package
v0.0.0-...-972b0a0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = &ErrResponse{
		HTTPStatusCode: http.StatusNotFound,
		StatusText:     "Resource not found",
	}
	ErrInternalServerError = &ErrResponse{
		HTTPStatusCode: http.StatusInternalServerError,
		StatusText:     "Internal server error",
	}
	ErrBadRequest = &ErrResponse{
		HTTPStatusCode: http.StatusBadRequest,
		StatusText:     "Bad request",
	}
)

Functions

func NewListPeopleResponse

func NewListPeopleResponse(peoples *dto.Peoples) []render.Renderer

Types

type CreatePeopleRequest

type CreatePeopleRequest struct {
	FirstName  string `json:"first_name"`
	LastName   string `json:"last_name"`
	Patronymic string `json:"patronymic"`
	Age        int    `json:"age"`
	Sex        string `json:"sex"`
	Nation     string `json:"nation"`
}

func (*CreatePeopleRequest) Bind

func (c *CreatePeopleRequest) Bind(r *http.Request) error

type ErrResponse

type ErrResponse struct {
	Err            error `json:"-"`
	HTTPStatusCode int   `json:"-"`

	StatusText string `json:"status"`
	AppCode    int64  `json:"code,omitempty"`
	ErrorText  string `json:"error,omitempty"`
}

func ErrUnprocessableEntity

func ErrUnprocessableEntity(err error) *ErrResponse

func (*ErrResponse) Render

func (e *ErrResponse) Render(w http.ResponseWriter, r *http.Request) error

type FilterRequest

type FilterRequest struct {
	Limit   int  `json:"limit"`
	Offset  int  `json:"offset"`
	Deleted bool `json:"deleted"`
}

func (*FilterRequest) Bind

func (f *FilterRequest) Bind(r *http.Request) error

type PeopleResponse

type PeopleResponse struct {
	ID         uuid.UUID `json:"id" db:"id"`
	FirstName  string    `json:"first_name" db:"first_name"`
	LastName   string    `json:"last_name" db:"last_name"`
	Patronymic string    `json:"patronymic" db:"patronymic"`
	Age        int       `json:"age" db:"age"`
	Sex        string    `json:"sex" db:"sex"`
	Nation     string    `json:"nation" db:"nation"`
	Deleted    bool      `json:"deleted" db:"deleted"`
}

func NewPeopleResponse

func NewPeopleResponse(people dto.People) *PeopleResponse

func (*PeopleResponse) Render

type UpdatePeopleRequest

type UpdatePeopleRequest struct {
	FirstName  string `json:"first_name"`
	LastName   string `json:"last_name"`
	Patronymic string `json:"patronymic"`
	Age        int    `json:"age"`
	Sex        string `json:"sex"`
	Nation     string `json:"nation"`
}

func (*UpdatePeopleRequest) Bind

func (u *UpdatePeopleRequest) Bind(r *http.Request) error

Jump to

Keyboard shortcuts

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