-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
response.go
57 lines (46 loc) · 1.22 KB
/
response.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package http_ns
import (
"github.com/inoxlang/inox/internal/core/symbolic"
"github.com/inoxlang/inox/internal/prettyprint"
pprint "github.com/inoxlang/inox/internal/prettyprint"
)
var (
ANY_RESP = &Response{}
HTTP_RESPONSE_PROPNAMES = []string{"body", "status", "status-code", "cookies"}
)
type Response struct {
symbolic.UnassignablePropsMixin
_ int
}
func (r *Response) Test(v symbolic.Value, state symbolic.RecTestCallState) bool {
state.StartCall()
defer state.FinishCall()
_, ok := v.(*Response)
return ok
}
func (resp *Response) GetGoMethod(name string) (*symbolic.GoFunction, bool) {
return nil, false
}
func (resp *Response) Prop(name string) symbolic.Value {
switch name {
case "body":
return &symbolic.Reader{}
case "status":
return symbolic.ANY_STRING
case "status-code":
return ANY_STATUS_CODE
case "cookies":
return symbolic.NewListOf(NewCookieObject())
default:
return symbolic.GetGoMethodOrPanic(name, resp)
}
}
func (*Response) PropertyNames() []string {
return HTTP_RESPONSE_PROPNAMES
}
func (r *Response) PrettyPrint(w prettyprint.PrettyPrintWriter, config *pprint.PrettyPrintConfig) {
w.WriteName("http-response")
}
func (r *Response) WidestOfType() symbolic.Value {
return &Response{}
}