1
1
package lars
2
2
3
3
import (
4
- "context"
5
4
"encoding/json"
6
5
"encoding/xml"
7
6
"io"
8
7
"net"
9
8
"net/http"
10
9
"strings"
11
- "time"
12
10
13
11
"github.com/gorilla/websocket"
14
12
)
@@ -24,45 +22,6 @@ type Param struct {
24
22
// It is therefore safe to read values by the index.
25
23
type Params []Param
26
24
27
- // Context is the context interface type
28
- type Context interface {
29
- context.Context
30
- Request () * http.Request
31
- Response () * Response
32
- WebSocket () * websocket.Conn
33
- Param (name string ) string
34
- ParseForm () error
35
- ParseMultipartForm (maxMemory int64 ) error
36
- Set (key interface {}, value interface {})
37
- Get (key interface {}) (value interface {}, exists bool )
38
- Context () context.Context
39
- WithContext (context.Context )
40
- WithCancel () context.CancelFunc
41
- WithDeadline (time.Time ) context.CancelFunc
42
- WithTimeout (time.Duration ) context.CancelFunc
43
- WithValue (key interface {}, val interface {})
44
- Next ()
45
- RequestStart (w http.ResponseWriter , r * http.Request )
46
- RequestEnd ()
47
- ClientIP () (clientIP string )
48
- AcceptedLanguages (lowercase bool ) []string
49
- HandlerName () string
50
- Stream (step func (w io.Writer ) bool )
51
- JSON (int , interface {}) error
52
- JSONBytes (int , []byte ) error
53
- JSONP (int , interface {}, string ) error
54
- XML (int , interface {}) error
55
- XMLBytes (int , []byte ) error
56
- Text (int , string ) error
57
- TextBytes (int , []byte ) error
58
- Attachment (r io.Reader , filename string ) (err error )
59
- Inline (r io.Reader , filename string ) (err error )
60
- Decode (includeFormQueryParams bool , maxMemory int64 , v interface {}) (err error )
61
- BaseContext () * Ctx
62
- }
63
-
64
- var _ context.Context = & Ctx {}
65
-
66
25
// NewContext returns a new default lars Context object.
67
26
func NewContext (l * LARS ) * Ctx {
68
27
0 commit comments