Documentation ¶
Overview ¶
Package server provides an executable server which exposes a REST API.
Package server provides an executable server which exposes a REST API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Driver string `json:"driver"` DSN string `json:"dsn"` Addr string `json:"addr"` }
Config concludes important configuration values which will be consumed by the API server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents an full-featured, executable REST API server. It is the central place where all individual components are being wired up.
It initializes and holds all storage objects as well as the business services. Each service requires multiple storage objects and the server will pass its own objects by reference to the corresponding services.
Since a service assumes that the storage objects are ready to use, each storage is initialized first and will then be passed to the service.
func New ¶
New is the actual entry point for the API server binary. It initializes all server components like the internal HTTP server or the router. Most importantly, it will create a database connection pool which will be passed to the storage factories, and the resulting storage object will be passed to the services.
This function is also the place where dependency injection happens: The server decides which storage implementations will be used - e. g. maria.Restaurant for the Server.restaurant field.