Added more tests
This commit is contained in:
15
Request.go
15
Request.go
@ -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
|
||||
|
Reference in New Issue
Block a user