contactapi

package module
v0.0.0-...-bbd9186 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2022 License: MIT Imports: 10 Imported by: 0

README

contact-api

That repository is related to implemented MongoDb client GoLang Web API.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectMongoDb

func ConnectMongoDb(url string) *mongo.Client

func Init

func Init(config Configuration)

Types

type Configuration

type Configuration struct {
	Database DatabaseSetting
	Server   ServerSettings
}

type Contact

type Contact struct {
	Id        int    `json:"id"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Email     string `json:"email"`
	Gender    string `json:"gender"`
	Phone     string `json:"phone"`
	City      string `json:"city"`
	Country   string `json:"country"`
}

type ContactHandler

type ContactHandler interface {
	GetAllContacts(*gin.Context)
	GetContactByEmail(*gin.Context)
	DeleteContact(*gin.Context)

	HealthCheck(*gin.Context)
}

func NewContactHandler

func NewContactHandler(client *mongo.Client, repo ContactRepository) ContactHandler

type ContactRepository

type ContactRepository interface {
	Get(ctx context.Context) ([]*Contact, error)
	GetContactByEmail(email string, ctx context.Context) (*Contact, error)
	Delete(id int, ctx context.Context) (int64, error)
}

func NewContactRepository

func NewContactRepository(config *Configuration, client *mongo.Client) ContactRepository

type DatabaseSetting

type DatabaseSetting struct {
	Url        string
	DbName     string
	Collection string
}

type ServerSettings

type ServerSettings struct {
	Port string
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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