Added request headers
This commit is contained in:
26
Request.go
26
Request.go
@ -4,6 +4,7 @@ import "git.akyoto.dev/go/router"
|
||||
|
||||
// Request is an interface for HTTP requests.
|
||||
type Request interface {
|
||||
Header(string) string
|
||||
Host() string
|
||||
Method() string
|
||||
Path() string
|
||||
@ -13,12 +14,25 @@ type Request interface {
|
||||
|
||||
// request represents the HTTP request used in the given context.
|
||||
type request struct {
|
||||
scheme string
|
||||
host string
|
||||
method string
|
||||
path string
|
||||
query string
|
||||
params []router.Parameter
|
||||
scheme string
|
||||
host string
|
||||
method string
|
||||
path string
|
||||
query string
|
||||
headers []header
|
||||
body []byte
|
||||
params []router.Parameter
|
||||
}
|
||||
|
||||
// Header returns the header value for the given key.
|
||||
func (req *request) Header(key string) string {
|
||||
for _, header := range req.headers {
|
||||
if header.Key == key {
|
||||
return header.Value
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
// Host returns the requested host.
|
||||
|
Reference in New Issue
Block a user