add csv reading, routing
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user