controller

package
v0.0.0-...-197e9dc Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2019 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTPHeaderAccept      = "Accept"
	HTTPHeaderContentType = "Content-Type"

	MIMETypeJSON           = "application/json"
	MIMETypeJSONProblem    = "application/problem+json"
	MIMETYPEFormURLEncoded = "application/x-www-form-urlencoded"
	MIMETypePlainText      = "text/plain"
	MimeTypeEverything     = "*/*"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func NewController

func NewController(db db.Model) *Controller

func (*Controller) Index

func (ctl *Controller) Index(w http.ResponseWriter, r *http.Request)

Just return 200, can be used as a Readiness probe

func (*Controller) RecordBirthday

func (ctl *Controller) RecordBirthday(w http.ResponseWriter, r *http.Request)

RecordBirthday is a PUT endpoint that fetches the name and the birthday date and stores it in the database

func (*Controller) TellBirthday

func (ctl *Controller) TellBirthday(w http.ResponseWriter, r *http.Request)

TellBirthday is a GET endpoint that returns the birthday of a person whose name is passed in the GET query string

type ErrorType

type ErrorType int
const (
	ErrUnsupportedMediaType ErrorType = iota + 1
	ErrDecodingJSON
	ErrParsingForm
	ErrMissingName
	ErrMissingRecord
	ErrMissingDateOfBirth
	ErrInvalidDateOfBirthFormat
	ErrDatabaseError
)

type TypedError

type TypedError struct {
	// contains filtered or unexported fields
}

func NewTypedError

func NewTypedError(kind ErrorType, message string) *TypedError

func (*TypedError) Error

func (e *TypedError) Error() string

Jump to

Keyboard shortcuts

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