Added more tests

This commit is contained in:
2024-03-27 20:41:27 +01:00
parent 98e1a47328
commit b6c208c75b
7 changed files with 211 additions and 144 deletions

View File

@ -8,6 +8,7 @@ type Request interface {
Method() string
Path() string
Scheme() string
Param(string) string
}
// request represents the HTTP request used in the given context.
@ -16,6 +17,7 @@ type request struct {
host string
method string
path string
query string
params []router.Parameter
}
@ -29,6 +31,19 @@ func (req *request) Method() string {
return req.method
}
// Param retrieves a parameter.
func (req *request) Param(name string) string {
for i := range len(req.params) {
p := req.params[i]
if p.Key == name {
return p.Value
}
}
return ""
}
// Path returns the requested path.
func (req *request) Path() string {
return req.path