server

package
v0.0.0-...-221c55c Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AnnouncementRequest

type AnnouncementRequest struct {
	Text     string   `json:"text"`
	Position Location `json:"position"`
}

func (AnnouncementRequest) Validate

func (r AnnouncementRequest) Validate() error

type AnnouncementResponse

type AnnouncementResponse struct {
	ID        string    `json:"id"`
	Text      string    `json:"text"`
	Position  Location  `json:"position"`
	ImageURL  string    `json:"imageURL"`
	CreatedAt time.Time `json:"createdAt"`
}

func ToAnnouncementResponses

func ToAnnouncementResponses(announcements []*model.Announcement) []AnnouncementResponse

type Config

type Config struct {
	Port                string
	AnnouncementStorage storage.AnnouncementStorage
	FileStorage         storage.FileStorage
	Statics             http.FileSystem
	DevMode             bool
	Checker             health.Checker
	FrontendConfig      map[string]any
}

type Filter

type Filter struct {
	North float64   `json:"north" query:"north"`
	East  float64   `json:"east" query:"east"`
	South float64   `json:"south" query:"south"`
	West  float64   `json:"west" query:"west"`
	After time.Time `json:"after" query:"after"`
}

func (Filter) Validate

func (f Filter) Validate() error

type Location

type Location struct {
	Lat float64 `json:"lat"`
	Lng float64 `json:"lng"`
}

type Server

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

func New

func New(cfg Config) (*Server, error)

func (*Server) Shutdown

func (srv *Server) Shutdown(ctx context.Context) error

func (*Server) Start

func (srv *Server) Start(ctx context.Context) error

type ValidationError

type ValidationError struct {
	Message string            `json:"message"`
	Fields  map[string]string `json:"fields"`
}

func NewValidationError

func NewValidationError(msg string) *ValidationError

func (*ValidationError) AppendIssue

func (e *ValidationError) AppendIssue(field, message string)

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) HasIssues

func (e *ValidationError) HasIssues() bool

Jump to

Keyboard shortcuts

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