router

package
v0.0.0-...-9864bbb Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInternalServer = &ErrResponse{HTTPStatusCode: 500, StatusText: "Internal server error."}
View Source
var ErrNotFound = &ErrResponse{HTTPStatusCode: 404, StatusText: "Resource not found."}
View Source
var ErrServiceUnavailable = &ErrResponse{HTTPStatusCode: 503, StatusText: "Service unavailable."}

Functions

func DeleteEmail

func DeleteEmail(w http.ResponseWriter, r *http.Request)

DeleteEmail deletes an email by its id.

func DeleteEmails

func DeleteEmails(w http.ResponseWriter, r *http.Request)

DeleteEmails deletes emails by their ids.

func ErrInvalidRequest

func ErrInvalidRequest(err error) render.Renderer

func GetEmailById

func GetEmailById(w http.ResponseWriter, r *http.Request)

GetEmailById returns an email by its id.

func GetEmailByMessageId

func GetEmailByMessageId(w http.ResponseWriter, r *http.Request)

GetEmailByMessageId returns an email by its message id.

func ListEmails

func ListEmails(w http.ResponseWriter, r *http.Request)

ListEmails returns a list of all emails in zinc.

func NewRouter

func NewRouter() http.Handler

NewRouter creates a new router

func QueryEmails

func QueryEmails(w http.ResponseWriter, r *http.Request)

QueryEmails returns a list of emails that match the query string. The query string comes as a query parameter.

func SearchEmails

func SearchEmails(w http.ResponseWriter, r *http.Request)

SearchEmails returns a list of emails that match the search query. The search query comes from the body of the request as a JSON object.

func UpdateEmail

func UpdateEmail(w http.ResponseWriter, r *http.Request)

UpdateEmail updates an email by its id.

func UpdateEmails

func UpdateEmails(w http.ResponseWriter, r *http.Request)

UpdateEmails updates multiple emails.

Types

type ErrResponse

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

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

ErrResponse renderer type for handling all sorts of errors.

In the best case scenario, the excellent github.com/pkg/errors package helps reveal information on the error, setting it on Err, and in the Render() method, using it to set the application-specific error code in AppCode.

func (*ErrResponse) Render

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

Jump to

Keyboard shortcuts

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