Added parameter retrieval
This commit is contained in:
parent
0c4519ea65
commit
4f6696fa44
2 changed files with 24 additions and 5 deletions
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue