2024-03-22 15:08:24 +01:00
|
|
|
package web
|
2024-03-16 15:22:47 +01:00
|
|
|
|
2024-03-26 22:46:16 +01:00
|
|
|
import "git.akyoto.dev/go/router"
|
2024-03-16 15:22:47 +01:00
|
|
|
|
|
|
|
// Request is an interface for HTTP requests.
|
|
|
|
type Request interface {
|
|
|
|
Method() string
|
|
|
|
Path() string
|
|
|
|
}
|
|
|
|
|
|
|
|
// request represents the HTTP request used in the given context.
|
|
|
|
type request struct {
|
2024-03-26 22:46:16 +01:00
|
|
|
method string
|
|
|
|
path string
|
|
|
|
params []router.Parameter
|
2024-03-16 15:22:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Method returns the request method.
|
2024-03-26 22:46:16 +01:00
|
|
|
func (req *request) Method() string {
|
|
|
|
return req.method
|
2024-03-16 15:22:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Path returns the requested path.
|
2024-03-26 22:46:16 +01:00
|
|
|
func (req *request) Path() string {
|
|
|
|
return req.path
|
2024-03-16 15:22:47 +01:00
|
|
|
}
|
|
|
|
|
2024-03-26 22:46:16 +01:00
|
|
|
// addParameter adds a new parameter to the request.
|
|
|
|
func (req *request) addParameter(key string, value string) {
|
|
|
|
req.params = append(req.params, router.Parameter{
|
|
|
|
Key: key,
|
|
|
|
Value: value,
|
|
|
|
})
|
2024-03-16 15:22:47 +01:00
|
|
|
}
|