-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhttp.go
More file actions
35 lines (28 loc) · 766 Bytes
/
http.go
File metadata and controls
35 lines (28 loc) · 766 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
package bgo
import (
"context"
"net/http"
httprouter "github.com/julienschmidt/httprouter"
)
// HTTP context
type HTTP struct {
Response http.ResponseWriter
Request *http.Request
Params httprouter.Params
}
// Request get request from context
func Request(ctx context.Context) *http.Request {
return value(ctx, "http").(*HTTP).Request
}
// Response get response from context
func Response(ctx context.Context) http.ResponseWriter {
return value(ctx, "http").(*HTTP).Response
}
// Params get params from context
func Params(ctx context.Context) httprouter.Params {
return value(ctx, "http").(*HTTP).Params
}
// Param get param from context
func Param(ctx context.Context, key string) string {
return value(ctx, "http").(*HTTP).Params.ByName(key)
}