Skip to content

Commit

Permalink
chore: rename custom url modifier, filter and verifier
Browse files Browse the repository at this point in the history
  • Loading branch information
imranismail committed Nov 25, 2020
1 parent da382f5 commit a860975
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
6 changes: 3 additions & 3 deletions bffurl/url_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ import (
"github.com/google/martian/v3/parse"
)

var noop = martian.Noop("bffurl.Filter")
var noop = martian.Noop("bff.URLFilter")

func init() {
parse.Register("bffurl.Filter", filterFromJSON)
parse.Register("bff.URLFilter", filterFromJSON)
}

// Filter runs modifiers iff the request URL matches all of the segments in url.
Expand All @@ -48,7 +48,7 @@ type filterJSON struct {
// NewFilter constructs a filter that applies the modifer when the
// request URL matches all of the provided URL segments.
func NewFilter(u *url.URL) *Filter {
log.Debugf("bffurl.NewFilter: %s", u)
log.Debugf("bff.NewURLFilter: %s", u)

m := NewMatcher(u)
f := filter.New()
Expand Down
11 changes: 7 additions & 4 deletions bffurl/url_modifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"net/url"

"github.com/google/martian/v3"
"github.com/google/martian/v3/log"
"github.com/google/martian/v3/parse"
)

Expand All @@ -42,7 +43,7 @@ type modifierJSON struct {
}

func init() {
parse.Register("bffurl.Modifier", modifierFromJSON)
parse.Register("bff.URLModifier", modifierFromJSON)
}

// ModifyRequest sets the fields of req.URL to m.Url if they are not the zero value.
Expand All @@ -68,10 +69,12 @@ func (m *Modifier) ModifyRequest(req *http.Request) error {
}

// NewModifier overrides the url of the request.
func NewModifier(url *url.URL) martian.RequestModifier {
func NewModifier(u *url.URL) martian.RequestModifier {
log.Debugf("bff.NewURLModifier: %s", u)

return &Modifier{
url: url,
pattern: NewPattern(url.Path),
url: u,
pattern: NewPattern(u.Path),
}
}

Expand Down
11 changes: 7 additions & 4 deletions bffurl/url_verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"strings"

"github.com/google/martian/v3"
"github.com/google/martian/v3/log"
"github.com/google/martian/v3/martianurl"
"github.com/google/martian/v3/parse"
"github.com/google/martian/v3/verify"
Expand All @@ -33,7 +34,7 @@ const (
)

func init() {
parse.Register("bffurl.Verifier", verifierFromJSON)
parse.Register("bff.URLVerifier", verifierFromJSON)
}

// Verifier verifies the structure of URLs.
Expand All @@ -52,11 +53,13 @@ type verifierJSON struct {
}

// NewVerifier returns a new URL verifier.
func NewVerifier(url *url.URL) verify.RequestVerifier {
func NewVerifier(u *url.URL) verify.RequestVerifier {
log.Debugf("bff.NewURLVerifier: %s", u)

return &Verifier{
url: url,
url: u,
err: martian.NewMultiError(),
pattern: NewPattern(url.Path),
pattern: NewPattern(u.Path),
}
}

Expand Down

0 comments on commit a860975

Please sign in to comment.