Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pkg/cep/newrequestwithcontext.correio.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ func NewRequestWithContextCorreio(ctx context.Context, cancel context.CancelFunc
wecep.Uf = c.Uf
wecep.Logradouro = c.End
wecep.Bairro = c.Bairro

b, err := json.Marshal(wecep)
if err == nil {
if err == nil && ValidCep(*wecep) {
chResult <- Result{Body: b}
cancel()
}
Expand Down
19 changes: 12 additions & 7 deletions pkg/cep/newrequestwithcontext.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ func NewRequestWithContext(ctx context.Context, cancel context.CancelFunc, cep,
case "republicavirtual":
republicavirtual(wecep, body, chResult, cancel)
case "cdnapicep":
println("cdnapicep")
cdnapicep(wecep, body, chResult, cancel)
case "brasilapi":
brasilapi(wecep, body, chResult, cancel)
Expand All @@ -74,8 +73,9 @@ func githubjeffotoni(wecep *models.WeCep, body []byte, chResult chan<- Result, c
wecep.Uf = githubjeff.Uf
wecep.Logradouro = githubjeff.Logradouro
wecep.Bairro = githubjeff.Bairro

b, err := json.Marshal(wecep)
if err == nil {
if err == nil && ValidCep(*wecep) {
chResult <- Result{Body: b}
cancel()
}
Expand All @@ -90,8 +90,9 @@ func viacep(wecep *models.WeCep, body []byte, chResult chan<- Result, cancel con
wecep.Uf = viacep.Uf
wecep.Logradouro = viacep.Logradouro
wecep.Bairro = viacep.Bairro

b, err := json.Marshal(wecep)
if err == nil {
if err == nil && ValidCep(*wecep) {
chResult <- Result{Body: b}
cancel()
}
Expand All @@ -106,8 +107,9 @@ func postmon(wecep *models.WeCep, body []byte, chResult chan<- Result, cancel co
wecep.Uf = postmon.Estado
wecep.Logradouro = postmon.Logradouro
wecep.Bairro = postmon.Bairro

b, err := json.Marshal(wecep)
if err == nil {
if err == nil && ValidCep(*wecep) {
chResult <- Result{Body: b}
cancel()
}
Expand All @@ -122,8 +124,9 @@ func republicavirtual(wecep *models.WeCep, body []byte, chResult chan<- Result,
wecep.Uf = repub.Uf
wecep.Logradouro = repub.Logradouro
wecep.Bairro = repub.Bairro

b, err := json.Marshal(wecep)
if err == nil {
if err == nil && ValidCep(*wecep) {
chResult <- Result{Body: b}
cancel()
}
Expand All @@ -138,8 +141,9 @@ func cdnapicep(wecep *models.WeCep, body []byte, chResult chan<- Result, cancel
wecep.Uf = cdnapi.State
wecep.Logradouro = cdnapi.Address
wecep.Bairro = cdnapi.District

b, err := json.Marshal(wecep)
if err == nil {
if err == nil && ValidCep(*wecep) {
chResult <- Result{Body: b}
cancel()
}
Expand All @@ -154,8 +158,9 @@ func brasilapi(wecep *models.WeCep, body []byte, chResult chan<- Result, cancel
wecep.Uf = brasilapi.State
wecep.Logradouro = brasilapi.Street
wecep.Bairro = brasilapi.Neighborhood

b, err := json.Marshal(wecep)
if err == nil {
if err == nil && ValidCep(*wecep) {
chResult <- Result{Body: b}
cancel()
}
Expand Down