2024-03-26 22:46:16 +01:00

35 lines
693 B
Go

package web
import "git.akyoto.dev/go/router"
// 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 {
method string
path string
params []router.Parameter
}
// Method returns the request method.
func (req *request) Method() string {
return req.method
}
// Path returns the requested path.
func (req *request) Path() string {
return req.path
}
// 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,
})
}