Skip to content

Commit 79d4b06

Browse files
committed
export ctx in context
1 parent e28f3d7 commit 79d4b06

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

context.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
type handlerFunc func(ctx *Context) error
99

1010
type Context struct {
11-
ctx *fasthttp.RequestCtx
11+
Ctx *fasthttp.RequestCtx
1212
params map[string]string
1313
paramValues []string
1414
handlers []handlerFunc
@@ -18,7 +18,7 @@ type Context struct {
1818
// NewContext returns a new Context.
1919
func NewContext(ctx *fasthttp.RequestCtx, params map[string]string) *Context {
2020
return &Context{
21-
ctx: ctx,
21+
Ctx: ctx,
2222
params: params,
2323
paramValues: make([]string, 0, 10),
2424
handlers: nil,
@@ -28,7 +28,7 @@ func NewContext(ctx *fasthttp.RequestCtx, params map[string]string) *Context {
2828

2929
// Context returns the fasthttp.RequestCtx
3030
func (c *Context) Context() *fasthttp.RequestCtx {
31-
return c.ctx
31+
return c.Ctx
3232
}
3333

3434
// WithParams sets the params for the context.
@@ -44,23 +44,23 @@ func (c *Context) Param(key string) string {
4444

4545
// String sets the response body to the given string.
4646
func (c *Context) String(value string) {
47-
if c.ctx.Response.Body() == nil {
48-
c.ctx.Response.SetBodyString(value)
47+
if c.Ctx.Response.Body() == nil {
48+
c.Ctx.Response.SetBodyString(value)
4949
} else {
50-
buf := bytes.NewBuffer(c.ctx.Response.Body())
50+
buf := bytes.NewBuffer(c.Ctx.Response.Body())
5151
buf.WriteString(value)
52-
c.ctx.Response.SetBody(buf.Bytes())
52+
c.Ctx.Response.SetBody(buf.Bytes())
5353
}
5454
}
5555

5656
// SetData sets the http header value to the given key.
5757
func (c *Context) SetData(key string, value interface{}) {
58-
c.ctx.Response.Header.Set(key, value.(string))
58+
c.Ctx.Response.Header.Set(key, value.(string))
5959
}
6060

6161
// GetData returns the http header value for the given key.
6262
func (c *Context) GetData(key string) string {
63-
return string(c.ctx.Response.Header.Peek(key))
63+
return string(c.Ctx.Response.Header.Peek(key))
6464
}
6565

6666
// Next calls the next handler in the chain.

0 commit comments

Comments
 (0)