http

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2024 License: MIT Imports: 13 Imported by: 1

README

http for GoJS

usage

import (
	"apigo.cc/gojs"
	_ "apigo.cc/gojs/http"
)

func main() {
	r, err := gojs.Run(`
import http from 'apigo.cc/gojs/http'

function main(args){
	return http.get('http://......')
}
	`, "test.js")

    fmt.Println(r, err)
}

websocket

import http from 'apigo.cc/gojs/http'
let conn http.connect('ws://......')
conn.write('hello world')
let r = conn.read()
conn.close()

module.exports

function new(config?: Config): Client
function newH2C(config?: Config): Client
function get(url: string, headers?: Object): Result
function head(url: string, headers?: Object): Result
function post(url: string, data: any, headers?: Object): Result
function put(url: string, data: any, headers?: Object): Result
function delete(url: string, data: any, headers?: Object): Result
function do(method: string, url: string, data: any, callback?: (data: string) => void, headers?: Object): Result
function upload(url: string, form: Object, files: Object, headers?: Object): Result
function download(filename: string, url: string, callback?: (finished: number, total: number) => void, headers?: Object): Result
function connect(url: string, config?: WSConfig): WS

full api see http.ts

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Http

type Http struct {
	// contains filtered or unexported fields
}

func (*Http) Connect

func (hc *Http) Connect(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

func (*Http) Delete

func (hc *Http) Delete(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

func (*Http) Do

func (hc *Http) Do(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

func (*Http) Download

func (hc *Http) Download(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

func (*Http) Get

func (hc *Http) Get(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

func (*Http) Head

func (hc *Http) Head(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

func (*Http) Post

func (hc *Http) Post(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

func (*Http) Put

func (hc *Http) Put(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

func (*Http) Upload

func (hc *Http) Upload(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

type WS

type WS struct {
	// contains filtered or unexported fields
}

func (*WS) Close

func (ws *WS) Close(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

func (*WS) Ping added in v0.0.3

func (ws *WS) Ping(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

func (*WS) PingCount added in v0.0.3

func (ws *WS) PingCount(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

func (*WS) Read

func (ws *WS) Read(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

func (*WS) Write

func (ws *WS) Write(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

func (*WS) WriteMessage added in v0.0.3

func (ws *WS) WriteMessage(argsIn goja.FunctionCall, vm *goja.Runtime) goja.Value

Jump to

Keyboard shortcuts

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