renderer

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: May 20, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = &ErrResponse{HTTPStatusCode: http.StatusNotFound, Message: http.StatusText(http.StatusNotFound)}

ErrNotFound represents a 404 error

View Source
var ErrUnauthorized = &ErrResponse{HTTPStatusCode: http.StatusUnauthorized, Message: http.StatusText(http.StatusUnauthorized)}

ErrUnauthorized represents a 401 error

Functions

func ErrBadRequest

func ErrBadRequest(err error) render.Renderer

ErrBadRequest represents a 400 error

func ErrConflict

func ErrConflict(err error) render.Renderer

ErrConflict represents a 409 error

func ErrGateway

func ErrGateway(err error) render.Renderer

ErrGateway represents a 504 error caused by unresponsive auxiliary servers

func ErrInternalServer

func ErrInternalServer(err error) render.Renderer

ErrInternalServer represents a 500 error

func ErrValidation

func ErrValidation(err error) render.Renderer

ErrValidation represents a 422 error caused by validation

func NewClientListResponse

func NewClientListResponse(clients []*model.Client) []render.Renderer

NewClientListResponse creates a new client list response from multiple client models

func NewPagerListResponse

func NewPagerListResponse(pagers []*model.Pager) []render.Renderer

NewPagerListResponse creates a new pager list response from multiple pager models

func NewPatientListResponse

func NewPatientListResponse(patients []*model.Patient) []render.Renderer

NewPatientListResponse creates a new patient list response from multiple patient models

func NewTokenListResponse

func NewTokenListResponse(tokens []*model.Token) []render.Renderer

NewTokenListResponse creates a new token list response from multiple token models

Types

type ClientListResponse

type ClientListResponse []*ClientResponse

ClientListResponse is the list response payload for the client data model

type ClientResponse

type ClientResponse struct {
	ID   uint   `json:"id"`
	Name string `json:"name"`
}

ClientResponse is the response payload for the client data model

func NewClientResponse

func NewClientResponse(client *model.Client) *ClientResponse

NewClientResponse creates a new client response from client model

func (*ClientResponse) Render

func (cr *ClientResponse) Render(w http.ResponseWriter, req *http.Request) error

Render preprocesses the response before marshalling

type ErrResponse

type ErrResponse struct {
	Err            error `json:"-"`      // low-level runtime error
	HTTPStatusCode int   `json:"status"` // http renderer status code

	Message   string `json:"message"`         // user-level status message
	ErrorText string `json:"error,omitempty"` // application-level error message, for debugging
}

ErrResponse renderer type for handling all sorts of errors.

func (*ErrResponse) Render

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

Render renders the ErrResponse

type PagerListResponse

type PagerListResponse []*PagerResponse

PagerListResponse is the list response payload for the pager data model

type PagerResponse

type PagerResponse struct {
	ID   uint   `json:"id"`
	Name string `json:"name"`
}

PagerResponse is the response payload for the pager data model

func NewPagerResponse

func NewPagerResponse(pager *model.Pager) *PagerResponse

NewPagerResponse creates a new pager response from pager model

func (*PagerResponse) Render

func (pr *PagerResponse) Render(w http.ResponseWriter, req *http.Request) error

Render preprocesses the response before marshalling

type PatientListResponse

type PatientListResponse []*PatientResponse

PatientListResponse is the list response payload for the patient data model

type PatientRequest

type PatientRequest struct {
	ID               uint   `json:"id"`
	SocialSecurityNo string `json:"ssn"`
	Name             string `json:"name"`
	PagerID          uint   `json:"pagerId"`
	ClientID         uint   `json:"clientId"`
	Status           string `json:"status"`
	Active           bool   `json:"active"`
}

PatientRequest is the request payload for patient data model

func (*PatientRequest) Bind

func (pr *PatientRequest) Bind(r *http.Request) error

Bind postprocesses the decoding of the request body

func (*PatientRequest) GetModel

func (pr *PatientRequest) GetModel() *model.Patient

GetModel returns a Patient model

type PatientResponse

type PatientResponse struct {
	ID               uint   `json:"id"`
	SocialSecurityNo string `json:"ssn"`
	Name             string `json:"name"`
	PagerID          uint   `json:"pagerId,omitempty"`
	ClientID         uint   `json:"clientId"`
	Status           string `json:"status"`
	Active           bool   `json:"active"`
}

PatientResponse is the response payload for the patient data model

func NewPatientResponse

func NewPatientResponse(patient *model.Patient) *PatientResponse

NewPatientResponse creates a new patient response from patient model

func (*PatientResponse) Render

Render preprocesses the response before marshalling

type TokenListResponse

type TokenListResponse []*TokenResponse

TokenListResponse is the list response payload for the token data model

type TokenResponse

type TokenResponse struct {
	Token string `json:"token"`
}

TokenResponse is the response payload for the token data model

func NewTokenResponse

func NewTokenResponse(token *model.Token) *TokenResponse

NewTokenResponse creates a new token response from token model

func (*TokenResponse) Render

func (cr *TokenResponse) Render(w http.ResponseWriter, req *http.Request) error

Render preprocesses the response before marshalling

type UserRequest

type UserRequest struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

UserRequest is the request payload for user data model

func (*UserRequest) Bind

func (pr *UserRequest) Bind(r *http.Request) error

Bind postprocesses the decoding of the request body

func (*UserRequest) GetModel

func (pr *UserRequest) GetModel() *model.User

GetModel returns a User model

Jump to

Keyboard shortcuts

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