handler

package
v0.0.0-...-3784b31 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

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)

func (*Handler) MainHandler

func (h *Handler) MainHandler(_ *http.Request) APIResponse

GET /

Jump to

Keyboard shortcuts

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