test

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

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

func (PGHandler) Get

func (h PGHandler) Get(w http.ResponseWriter, r *http.Request)

Get is a function that is called to pull data from the database

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

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

type TodoModel

type TodoModel struct {
	UserID    int    `json:"userId"`
	ID        int    `json:"id"`
	Title     string `json:"title"`
	Completed bool   `json:"completed"`
}

TodoModel is a struct that represents the API response

Jump to

Keyboard shortcuts

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