Added URL parsing
This commit is contained in:
14
Request.go
14
Request.go
@ -4,17 +4,26 @@ import "git.akyoto.dev/go/router"
|
||||
|
||||
// Request is an interface for HTTP requests.
|
||||
type Request interface {
|
||||
Host() string
|
||||
Method() string
|
||||
Path() string
|
||||
Scheme() string
|
||||
}
|
||||
|
||||
// request represents the HTTP request used in the given context.
|
||||
type request struct {
|
||||
scheme string
|
||||
host string
|
||||
method string
|
||||
path string
|
||||
params []router.Parameter
|
||||
}
|
||||
|
||||
// Host returns the requested host.
|
||||
func (req *request) Host() string {
|
||||
return req.host
|
||||
}
|
||||
|
||||
// Method returns the request method.
|
||||
func (req *request) Method() string {
|
||||
return req.method
|
||||
@ -25,6 +34,11 @@ func (req *request) Path() string {
|
||||
return req.path
|
||||
}
|
||||
|
||||
// Scheme returns either `http`, `https` or an empty string.
|
||||
func (req request) Scheme() string {
|
||||
return req.scheme
|
||||
}
|
||||
|
||||
// addParameter adds a new parameter to the request.
|
||||
func (req *request) addParameter(key string, value string) {
|
||||
req.params = append(req.params, router.Parameter{
|
||||
|
Reference in New Issue
Block a user