diff --git a/cmd/restapi/main.go b/cmd/restapi/main.go index c693eac..9c2ba7b 100644 --- a/cmd/restapi/main.go +++ b/cmd/restapi/main.go @@ -6,13 +6,13 @@ import ( "github.com/gofiber/fiber/v2" "github.com/gofiber/fiber/v2/middleware/recover" "github.com/rs/zerolog/log" - "github.com/th0th/is-email-disposable/pkg/common" + "github.com/th0th/is-email-disposable/pkg/isemaildisposable" "github.com/th0th/is-email-disposable/pkg/restapi/handler" "github.com/th0th/is-email-disposable/pkg/service/domain" ) func main() { - common.LogSetDefaults() + isemaildisposable.LogSetDefaults() domainService, err := domain.New() if err != nil { diff --git a/pkg/common/domain.go b/pkg/isemaildisposable/domain.go similarity index 86% rename from pkg/common/domain.go rename to pkg/isemaildisposable/domain.go index 892fddf..daa2a0d 100644 --- a/pkg/common/domain.go +++ b/pkg/isemaildisposable/domain.go @@ -1,4 +1,4 @@ -package common +package isemaildisposable type DomainService interface { Check(emailOrDomain string) *DomainServiceCheckResult diff --git a/pkg/common/log.go b/pkg/isemaildisposable/log.go similarity index 96% rename from pkg/common/log.go rename to pkg/isemaildisposable/log.go index 4c976e2..30e3da7 100644 --- a/pkg/common/log.go +++ b/pkg/isemaildisposable/log.go @@ -1,4 +1,4 @@ -package common +package isemaildisposable import ( "strconv" diff --git a/pkg/restapi/handler/main.go b/pkg/restapi/handler/main.go index f64bcbf..dfad7ba 100644 --- a/pkg/restapi/handler/main.go +++ b/pkg/restapi/handler/main.go @@ -3,14 +3,14 @@ package handler import ( "github.com/go-errors/errors" "github.com/gofiber/fiber/v2" - "github.com/th0th/is-email-disposable/pkg/common" + "github.com/th0th/is-email-disposable/pkg/isemaildisposable" ) type indexQueryParams struct { EmailOrDomain *string `query:"email"` } -func Index(domainService common.DomainService) fiber.Handler { +func Index(domainService isemaildisposable.DomainService) fiber.Handler { return func(c *fiber.Ctx) error { queryParams := indexQueryParams{} err := c.QueryParser(&queryParams) diff --git a/pkg/service/domain/main.go b/pkg/service/domain/main.go index 00db1c8..e30a103 100644 --- a/pkg/service/domain/main.go +++ b/pkg/service/domain/main.go @@ -6,14 +6,14 @@ import ( "strings" "github.com/go-errors/errors" - "github.com/th0th/is-email-disposable/pkg/common" + "github.com/th0th/is-email-disposable/pkg/isemaildisposable" ) type service struct { domainsMap map[string]bool } -func New() (common.DomainService, error) { +func New() (isemaildisposable.DomainService, error) { csvReader := csv.NewReader(strings.NewReader(domainsCsvFile)) records, err := csvReader.ReadAll() if err != nil { @@ -30,7 +30,7 @@ func New() (common.DomainService, error) { }, nil } -func (s *service) Check(emailOrDomain string) *common.DomainServiceCheckResult { +func (s *service) Check(emailOrDomain string) *isemaildisposable.DomainServiceCheckResult { domain := emailOrDomain atIndex := strings.LastIndex(emailOrDomain, "@") @@ -38,7 +38,7 @@ func (s *service) Check(emailOrDomain string) *common.DomainServiceCheckResult { domain = emailOrDomain[atIndex+1:] } - return &common.DomainServiceCheckResult{ + return &isemaildisposable.DomainServiceCheckResult{ IsDisposable: s.domainsMap[domain], } }