Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Module = fx.Provide( NewRedisHandler, NewPGHandler, NewHTTPHandler, fx.Annotated{ Group: "server", Target: RegisterHandler, }, )
Module allows the routes from this module to be registered to the app
Functions ¶
func RegisterHandler ¶
func RegisterHandler(params HandlerParams) router.Module
RegisterHandler registers the handlers to the router
Types ¶
type DBResponse ¶
type DBResponse struct {
Result int64 `json:"result" db:"result"`
}
DBResponse is the model that represents the response from the database
type HTTPHandler ¶
type HTTPHandler struct { ResponseProvider response.ResponderProvider Logger *zap.Logger Client *http.Client }
HTTPHandler is a type that will reach out to a third party service
func NewHTTPHandler ¶
func NewHTTPHandler(provider response.ResponderProvider, logger *zap.Logger, client *http.Client) HTTPHandler
NewHTTPHandler produces a new instance of the HTTPHandler type
func (HTTPHandler) Get ¶
func (h HTTPHandler) Get(w http.ResponseWriter, r *http.Request)
Get is the function that is called when the route is hit
type HandlerParams ¶
type HandlerParams struct { fx.In RedisHandler RedisHandler PGHandler PGHandler HTTPHandler HTTPHandler }
HandlerParams is the type that defines the parameters that are required to register the handlers to the router
type PGHandler ¶
type PGHandler struct { DB *sqlx.DB ResponseProvider response.ResponderProvider // contains filtered or unexported fields }
PGHandler is the handler that communicates with a postgres database
func NewPGHandler ¶
func NewPGHandler(db *sqlx.DB, logger *zap.Logger, responseProvider response.ResponderProvider) PGHandler
NewPGHandler is a function that creates a new instance of the PGHandler type
type RedisHandler ¶
type RedisHandler struct { Redis redis.Cmdable ResponseProvider response.ResponderProvider }
RedisHandler is the handler
func NewRedisHandler ¶
func NewRedisHandler(redisClient redis.Cmdable, responder response.ResponderProvider) RedisHandler
NewRedisHandler is the constructor for RedisHandler
func (RedisHandler) Get ¶
func (h RedisHandler) Get(rw http.ResponseWriter, r *http.Request)
Get is the function that is called when the route is routed to
type RedisResponse ¶
type RedisResponse struct {
Count int64 `json:"count"`
}
RedisResponse is the response returned by the RedisHandler