handlers

package
v0.0.0-...-760f05f Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//BuildTime holds binary build time information
	BuildTime string
	//VersionAPI holds binary version information
	VersionAPI string
	//CommitSHA holds last commit hash information
	CommitSHA string
	//GoVersion holds Golang version information
	GoVersion string
)

Functions

This section is empty.

Types

type BuildData

type BuildData struct {
	API    string
	Time   string
	SHA    string
	Golang string
}

BuildData is a struct holding all build information

type Docs

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

Docs is a handler struct used to handle documentation calls

func NewDocs

func NewDocs(swaggerFile string) *Docs

NewDocs is a factory method to create Docs service handler with defined Swagger YAML file path

func (*Docs) GetDocumentation

func (docs *Docs) GetDocumentation(response http.ResponseWriter, request *http.Request)

GetDocumentation is used to serve doc handle

swagger:route GET /docs utilities getDocumentation Returns a HTML and JS page with this documentation<br> NOTE: This page was auto-generated by ReDoc (https://github.com/Redocly/redoc) responses:

200: responseDocumentation

func (*Docs) GetSwagger

func (docs *Docs) GetSwagger(response http.ResponseWriter, request *http.Request)

GetSwagger is used to retrieve Swagger YAML file

swagger:route GET /resources/swagger.yaml utilities getSwagger Returns swagger.yaml configuration file needed for generating this documentation<br> NOTE: This file should be located in resources directory responses:

200: responseSwagger
404: errorSwagger

type Events

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

Events is a service handler responsible for getting and updating events

func NewEvents

func NewEvents(logger *log.Logger, validator *utils.Validator, database dataservice.Database) *Events

NewEvents is a factory method to create Events service handler with defined logger

func (*Events) AddEvent

func (events *Events) AddEvent(response http.ResponseWriter, request *http.Request)

AddEvent is used to add new event and store it in DB

swagger:route POST /events events addEvent Creates a new event and adds it to DB responses:

200: responsePostEvent
400: errorBadQuery
422: errorValidation
500: errorInternal

func (*Events) DeleteEvent

func (events *Events) DeleteEvent(response http.ResponseWriter, request *http.Request)

DeleteEvent is used to delete event with specified ID stored in DB

swagger:route DELETE /events/{id} events deleteEvent Deletes an event from DB by specified ID parameter responses:

204: responseNoContent
400: errorBadQuery

func (*Events) GetEvent

func (events *Events) GetEvent(response http.ResponseWriter, request *http.Request)

GetEvent is used to retrieve stored events with specified ID

swagger:route GET /event/{id} events getEvent Returns a event with provided id responses:

200: responseGetEvent
404: errorNotFound
500: errorInternal

func (*Events) GetEvents

func (events *Events) GetEvents(response http.ResponseWriter, request *http.Request)

GetEvents is used to retrieve currently stored events

swagger:route GET /events events getEvents Returns a list of currently stored events (all if no query params is used or filtered otherwise) responses:

200: responseGetEvents
400: errorBadQuery
500: errorInternal

func (*Events) UpdateEvent

func (events *Events) UpdateEvent(response http.ResponseWriter, request *http.Request)

UpdateEvent is used to update event with specified ID stored in DB

swagger:route PUT /events/{id} events updateEvent Updates an event in DB by specified ID parameter responses:

200: responsePutEvent
400: errorBadQuery
422: errorValidation
500: errorInternal

func (*Events) ValidationMiddleware

func (events *Events) ValidationMiddleware(next http.Handler) http.Handler

ValidationMiddleware is used to parse and validate Event from request

type Home

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

Home is a service handler used after visiting main service URL

func NewHome

func NewHome(html string, logger *log.Logger, config *utils.Config) *Home

NewHome is a factory method to create Home service handler

func (*Home) GetHealth

func (home *Home) GetHealth(response http.ResponseWriter, request *http.Request)

GetHealth is used to serve service health check

func (*Home) GetIndex

func (home *Home) GetIndex(response http.ResponseWriter, request *http.Request)

GetIndex is used to serve main page of service

type HomeData

type HomeData struct {
	Build  *BuildData
	Config *utils.Config
}

HomeData is a struct for storing data displayed in index.html

type KeyEvent

type KeyEvent struct{}

KeyEvent is a key used for add and get the Event object in the context

Jump to

Keyboard shortcuts

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