40 lines
543 B
Go
40 lines
543 B
Go
package httpx
|
|
|
|
import (
|
|
"github.com/d5/tengo/v2"
|
|
"net/http"
|
|
//"log"
|
|
)
|
|
|
|
type Request struct {
|
|
tengo.ObjectImpl
|
|
*http.Request
|
|
}
|
|
|
|
func (r *Request) TypeName() string {
|
|
return "*http.Request"
|
|
}
|
|
|
|
func (r *Request) String() string {
|
|
return "*http.Request{...}"
|
|
}
|
|
|
|
func (r *Request) IndexGet(
|
|
index tengo.Object,
|
|
) (tengo.Object, error) {
|
|
key, ok := tengo.ToString(index)
|
|
if !ok {
|
|
return nil, tengo.ErrInvalidIndexValueType
|
|
}
|
|
|
|
switch key {
|
|
case "url" :
|
|
return &URL{
|
|
URL: r.URL,
|
|
}, nil
|
|
}
|
|
|
|
// Nothing found.
|
|
return nil, nil
|
|
}
|
|
|