-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext.go
More file actions
41 lines (39 loc) · 1003 Bytes
/
context.go
File metadata and controls
41 lines (39 loc) · 1003 Bytes
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
package web
import (
"context"
"net/http"
)
// Context is the app-facing HTTP context contract.
type Context interface {
Context() context.Context
Method() string
Path() string
URI() string
Scheme() string
Host() string
Param(name string) string
Query(name string) string
Header(name string) string
Cookie(name string) (*http.Cookie, error)
RealIP() string
Request() *http.Request
SetRequest(request *http.Request)
Response() Response
ResponseWriter() http.ResponseWriter
SetResponseWriter(writer http.ResponseWriter)
Bind(target any) error
Set(key string, value any)
Get(key string) any
AddHeader(name string, value string)
SetHeader(name string, value string)
SetCookie(cookie *http.Cookie)
JSON(code int, payload any) error
Blob(code int, contentType string, body []byte) error
File(path string) error
Text(code int, body string) error
HTML(code int, body string) error
NoContent(code int) error
Redirect(code int, url string) error
StatusCode() int
Native() any
}