tbhttp

package
v0.0.0-...-1256235 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProtoHttp  = "http://"
	ProtoHttps = "https://"
)

Variables

View Source
var (
	ErrNoMethod = errors.New("no method")
)

Functions

func OttoValue2HttpReq

func OttoValue2HttpReq(req otto.Value) (*http.Request, error)
{
	"Method": "GET",
	"Host": "www.baidu.com",
	"Path": "/",
	"Query": {
		"type": "movie",
	},
	"Header": {
		"X-REAL-IP": "192.168.180.56"
	},
	"Body": ""
}

func TbRsp2OttoValue

func TbRsp2OttoValue(rsp *Response) (otto.Value, error)

Types

type Request

type Request struct {
	Method string
	Host   string
	Url    string
	Query  map[string]string
	Header map[string]string
	Body   string
}

func HttpReq2TbReq

func HttpReq2TbReq(req *http.Request) (*Request, error)

type Response

type Response struct {
	Status int
	Header map[string]string
	Body   string
}

func HttpRsp2TbRsp

func HttpRsp2TbRsp(rsp *http.Response) (*Response, error)

func OttoValue2TbRsp

func OttoValue2TbRsp(rsp otto.Value) (*Response, error)
{
	"status": 200,
	"header": {
		"Content-Type": "text/json"
	},
	"body": "{'foo': "bar"}"
}

type TbHttp

type TbHttp struct{}

func (*TbHttp) DoRequest

func (tbhttp *TbHttp) DoRequest(call otto.FunctionCall) otto.Value

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL