Skip to content

Commit

Permalink
ECOM-12344 feat: add new redirect codes
Browse files Browse the repository at this point in the history
  • Loading branch information
cvejk committed Dec 11, 2024
1 parent b235a45 commit 4946e34
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The redirects service provides an API that the frontend and the site-gateway ser
##### Search

```go
func (rs *Service) Search(_ http.ResponseWriter, r *http.Request, locale, path string) (map[redirectstore.RedirectSource]*redirectstore.RedirectDefinition, *redirectstore.RedirectDefinitionError)
func (rs *Service) Search(_ http.ResponseWriter, r *http.Request, locale, path string, page, pageSize int) (*redirectrepository.PaginatedResult, *redirectstore.RedirectDefinitionError)
```
Search for a redirect.

Expand Down
17 changes: 10 additions & 7 deletions domain/redirectdefinition/store/redirect.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import (
)

const (
RedirectCodePermanent RedirectCode = 301
RedirectCodeTemporary RedirectCode = 307 // will this be needed?
RedirectCodePermanent RedirectCode = 301 // Permanent Redirect
RedirectCodeFound RedirectCode = 302 // Temporary Redirect (Found)
RedirectCodeTemporary RedirectCode = 307 // Temporary Redirect with method preservation
RedirectCodeNotFound RedirectCode = 404 // Resource Not Found
RedirectCodeGone RedirectCode = 410 // Resource Gone
)

type RedirectResponse string
Expand All @@ -19,11 +22,11 @@ type Redirect struct {

func (r RedirectCode) Valid() bool {
switch r {
case
RedirectCodePermanent:
return true
case
RedirectCodeTemporary: // will this be needed
case RedirectCodePermanent,
RedirectCodeFound,
RedirectCodeTemporary,
RedirectCodeNotFound,
RedirectCodeGone:
return true
default:
return false
Expand Down

0 comments on commit 4946e34

Please sign in to comment.