25 lines
368 B
Go
25 lines
368 B
Go
package internal
|
|
|
|
type Redirect struct {
|
|
From string
|
|
To string
|
|
StatusCode int
|
|
}
|
|
|
|
func (r *Redirect) Match(from string) bool {
|
|
return from == r.From
|
|
}
|
|
|
|
type Redirects []*Redirect
|
|
|
|
func (rs Redirects) Find(from string) *Redirect {
|
|
for i := 0; i < len(rs); i++ {
|
|
redirect := rs[i]
|
|
if redirect.Match(from) {
|
|
return redirect
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|