Documentation ¶
Index ¶
- type APIResponse
- type Handler
- func (h *Handler) Error(code int, err error) APIResponse
- func (h *Handler) EventCreateHandler(req *http.Request) APIResponse
- func (h *Handler) EventDeleteHandler(req *http.Request) APIResponse
- func (h *Handler) EventUpdateHandler(req *http.Request) APIResponse
- func (h *Handler) EventsForDayHandler(req *http.Request) APIResponse
- func (h *Handler) EventsForMonthHandler(req *http.Request) APIResponse
- func (h *Handler) EventsForWeekHandler(req *http.Request) APIResponse
- func (h *Handler) Handle(fn func(req *http.Request) APIResponse) func(resp http.ResponseWriter, req *http.Request)
- func (h *Handler) JSON(code int, data interface{}) APIResponse
- func (h *Handler) MainHandler(_ *http.Request) APIResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIResponse ¶
type APIResponse func(resp http.ResponseWriter)
APIReponse Function for marshaling and sending data
type Handler ¶
type Handler struct { Storage domain.StorageInterface Logger *logrus.Logger }
Handler for processing API endpoints
func (*Handler) Error ¶
func (h *Handler) Error(code int, err error) APIResponse
Error Send data in JSON format (error)
func (*Handler) EventCreateHandler ¶
func (h *Handler) EventCreateHandler(req *http.Request) APIResponse
EventCreateHandler Add new event to storage POST /create_event Fields:
title: string date_from: datetime, format 2006-01-02T12:00:00Z date_to: datetime, format 2006-01-02T13:00:00Z
func (*Handler) EventDeleteHandler ¶
func (h *Handler) EventDeleteHandler(req *http.Request) APIResponse
EventDeleteHandler Delete event from storage if exists POST /delete_event Fields:
id : UUID
func (*Handler) EventUpdateHandler ¶
func (h *Handler) EventUpdateHandler(req *http.Request) APIResponse
EventUpdateHandler Update event by ID if exists POST /update_event Fields:
id: UUID title: string date_from: datetime, format 2006-01-02T12:00:00Z date_to: datetime, format 2006-01-02T13:00:00Z
func (*Handler) EventsForDayHandler ¶
func (h *Handler) EventsForDayHandler(req *http.Request) APIResponse
EventsForDayHandler Try to find events for day GET /events_for_day Fields:
start_day: format 2006-01-02
func (*Handler) EventsForMonthHandler ¶
func (h *Handler) EventsForMonthHandler(req *http.Request) APIResponse
EventsForMonthHandler Try to find events for month GET /events_for_month Fields:
start_day: format 2006-01-02
func (*Handler) EventsForWeekHandler ¶
func (h *Handler) EventsForWeekHandler(req *http.Request) APIResponse
EventsForWeekHandler Try to find events for week GET /events_for_week Fields:
start_day: format 2006-01-02
func (*Handler) Handle ¶
func (h *Handler) Handle(fn func(req *http.Request) APIResponse) func(resp http.ResponseWriter, req *http.Request)
Handle Wrap handler fucntion for http server
func (*Handler) JSON ¶
func (h *Handler) JSON(code int, data interface{}) APIResponse
JSON Send data in JSON format(success)