Documentation ¶
Overview ¶
Copyright [2020-2021] [guonaihong] Apache 2.0
Copyright [2020-2021] [guonaihong] Apache 2.0
Copyright [2020-2021] [guonaihong] Apache 2.0
Index ¶
Constants ¶
View Source
const ( EncodeWWWForm = "www-form" EncodeJSON = "json" EncodeYAML = "yaml" )
Variables ¶
View Source
var ( ErrSingleQuotes = errors.New("unquoted single quote") ErrDoubleQuotes = errors.New("unquoted double quote") ErrUnknown = errors.New("pcurl:GetArgsToken:unknown error") )
View Source
var ErrUnknownEncode = errors.New("Unknown encoder")
Functions ¶
func GetArgsToken ¶
TODO 考虑转义 TODO 各种换行符号
func ParseAndJSON ¶ added in v0.0.8
Types ¶
type Curl ¶
type Curl struct { Method string `clop:"-X; --request" usage:"Specify request command to use"` Get bool `clop:"-G; --get" usage:"Put the post data in the URL and use GET"` Header []string `clop:"-H; --header" usage:"Pass custom header(s) to server"` Data string `clop:"-d; --data" usage:"HTTP POST data"` DataRaw string `clop:"--data-raw" usage:"HTTP POST data, '@' allowed"` Form []string `clop:"-F; --form" usage:"Specify multipart MIME data"` URL2 string `clop:"args=url2" usage:"url2"` URL string `clop:"--url" usage:"URL to work with"` Location bool `clop:"-L; --location" usage:"Follow redirects"` //TODO DataUrlencode []string `clop:"--data-urlencode" usage:"HTTP POST data url encoded"` Compressed bool `clop:"--compressed" usage:"Request compressed response"` // 在响应包里面打印http header, 仅做字段赋值 Include bool `` /* 193-byte string literal not displayed */ Insecure bool `clop:"-k; --insecure" usage:"Allow insecure server connections when using SSL"` Err error // contains filtered or unexported fields }
Curl结构体
func ParseSlice ¶
ParseSlice和ParseString的区别,ParseSlice里面保存解析好的curl表达式
func ParseString ¶
ParseString是链式API结构, 如果要拿*http.Request,后接Request()即可
type Encode ¶ added in v0.0.8
type Encode struct { // x-www-form-urlencoded Body string `json:"body,omitempty" yaml:"body"` }
type Req ¶ added in v0.0.8
type Req struct { Method string `json:"method,omitempty" yaml:"method"` URL string `json:"url,omitempty" yaml:"url"` Encode Encode `json:"encode,omitempty" yaml:"encode"` Body any `json:"body,omitempty" yaml:"body"` Header []string `json:"header,omitempty" yaml:"header"` }
func ParseAndObj ¶ added in v0.0.8
解析curl字符串形式表达式,并返回结构体
Click to show internal directories.
Click to hide internal directories.