Added parameter retrieval
This commit is contained in:
12
Context.go
12
Context.go
@ -14,6 +14,7 @@ const maxParams = 16
|
||||
type Context interface {
|
||||
Bytes([]byte) error
|
||||
Error(status int, messages ...any) error
|
||||
Get(param string) string
|
||||
Reader(io.Reader) error
|
||||
SetStatus(status int)
|
||||
String(string) error
|
||||
@ -60,6 +61,17 @@ func (ctx *context) Error(status int, messages ...any) error {
|
||||
return errors.Join(combined...)
|
||||
}
|
||||
|
||||
// Get retrieves a parameter.
|
||||
func (ctx *context) Get(param string) string {
|
||||
for i := 0; i < ctx.paramCount; i++ {
|
||||
if ctx.paramNames[i] == param {
|
||||
return ctx.paramValues[i]
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
}
|
||||
|
||||
// Reader sends the contents of the io.Reader without creating an in-memory copy.
|
||||
func (ctx *context) Reader(reader io.Reader) error {
|
||||
_, err := io.Copy(ctx.response, reader)
|
||||
|
Reference in New Issue
Block a user