forked from gobuffalo/buffalo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
context.go
43 lines (38 loc) · 1016 Bytes
/
context.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package buffalo
import (
"context"
"net/http"
"github.com/gorilla/websocket"
"github.com/gobuffalo/buffalo/binding"
"github.com/gobuffalo/buffalo/render"
)
// Context holds on to information as you
// pass it down through middleware, Handlers,
// templates, etc... It strives to make your
// life a happier one.
type Context interface {
context.Context
Response() http.ResponseWriter
Request() *http.Request
Session() *Session
Cookies() *Cookies
Params() ParamValues
Param(string) string
Set(string, interface{})
LogField(string, interface{})
LogFields(map[string]interface{})
Logger() Logger
Bind(interface{}) error
Render(int, render.Renderer) error
Error(int, error) error
Websocket() (*websocket.Conn, error)
Redirect(int, string, ...interface{}) error
Data() map[string]interface{}
Flash() *Flash
File(string) (binding.File, error)
}
// ParamValues will most commonly be url.Values,
// but isn't it great that you set your own? :)
type ParamValues interface {
Get(string) string
}