Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new redirect objects #226

Merged
merged 9 commits into from
May 31, 2024
Prev Previous commit
Next Next commit
Change not found handling
  • Loading branch information
fformica committed Jan 29, 2024
commit 27587a3a930b8457be9631b627f005b990d8c7c8
7 changes: 4 additions & 3 deletions rest/redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"net/http"
"strings"

"gopkg.in/ns1/ns1-go.v2/rest/model/redirect"
)
Expand Down Expand Up @@ -51,7 +52,7 @@ func (s *RedirectService) Get(cfgId string) (*redirect.Configuration, *http.Resp
if err != nil {
switch err := err.(type) {
case *Error:
if err.Message == "configuration not found" {
if strings.HasSuffix(err.Message, " not found") {
return nil, resp, ErrRedirectNotFound
}
}
Expand Down Expand Up @@ -109,7 +110,7 @@ func (s *RedirectService) Update(cfg *redirect.Configuration) (*redirect.Configu
if err != nil {
switch err := err.(type) {
case *Error:
if err.Message == "configuration not found" {
if strings.HasSuffix(err.Message, " not found") {
return nil, resp, ErrRedirectNotFound
}
}
Expand All @@ -134,7 +135,7 @@ func (s *RedirectService) Delete(cfgId string) (*http.Response, error) {
if err != nil {
switch err := err.(type) {
case *Error:
if err.Message == "configuration not found" {
if strings.HasSuffix(err.Message, " not found") {
return resp, ErrRedirectNotFound
}
}
Expand Down
7 changes: 4 additions & 3 deletions rest/redirect_certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"net/http"
"strings"

"gopkg.in/ns1/ns1-go.v2/rest/model/redirect"
)
Expand Down Expand Up @@ -51,7 +52,7 @@ func (s *RedirectCertificateService) Get(certId string) (*redirect.Certificate,
if err != nil {
switch err := err.(type) {
case *Error:
if err.Message == "certificate not found" {
if strings.HasSuffix(err.Message, " not found") {
return nil, resp, ErrRedirectCertificateNotFound
}
}
Expand Down Expand Up @@ -104,7 +105,7 @@ func (s *RedirectCertificateService) Update(certId string) (*http.Response, erro
if err != nil {
switch err := err.(type) {
case *Error:
if err.Message == "certificate not found" {
if strings.HasSuffix(err.Message, " not found") {
return resp, ErrRedirectCertificateNotFound
}
}
Expand All @@ -129,7 +130,7 @@ func (s *RedirectCertificateService) Delete(certId string) (*http.Response, erro
if err != nil {
switch err := err.(type) {
case *Error:
if err.Message == "certificate not found" {
if strings.HasSuffix(err.Message, " not found") {
return resp, ErrRedirectCertificateNotFound
}
}
Expand Down
Loading