http

package
v0.0.0-...-ffc1c0f Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiHttp

type ApiHttp struct {
	Name string `yaml:"name"`

	Method   string   `yaml:"method"`
	URL      string   `yaml:"url"`
	Request  Request  `yaml:"request"`
	Response Response `yaml:"-"`

	BeforeScript       []LineField[string] `yaml:"before"`
	IgnoreParentBefore bool                `yaml:"ignore_parent_before"`
	AfterScript        []LineField[string] `yaml:"after"`
	IgnoreParentAfter  bool                `yaml:"ignore_parent_after"`

	// 变量
	Variables Variables `yaml:"variables"`

	Test test.TestManager `yaml:"-"`
	// contains filtered or unexported fields
}

func (*ApiHttp) Do

func (h *ApiHttp) Do(sessionDB *storage.KeyValueStore) (result ApiResult, err error)

func (*ApiHttp) Load

func (h *ApiHttp) Load(workDir string, name string) (err error)

type ApiResult

type ApiResult struct {
	Name   string `yaml:"name,omitempty"`
	URL    string `yaml:"url"`
	Method string `yaml:"method"`

	ID string `yaml:"id,omitempty"`

	Time time.Duration `yaml:"time"`

	StatusCode int    `yaml:"status_code,omitempty"`
	Status     string `yaml:"status,omitempty"`

	Request  RequestResult  `yaml:"request"`
	Response ResponseResult `yaml:"response"`

	Error string `yaml:"error,omitempty"`

	Tests test.TestManager `yaml:"tests,omitempty"`
}

func (*ApiResult) Pass

func (ar *ApiResult) Pass() bool

type LineField

type LineField[T any] struct {
	File  string
	Line  int
	Value T
}

func (*LineField[T]) UnmarshalYAML

func (f *LineField[T]) UnmarshalYAML(node *yaml.Node) (err error)

解析yaml

type Request

type Request struct {
	Param  map[string]string `yaml:"param,omitempty"`
	Header map[string]string `yaml:"header,omitempty"`
	Cookie map[string]string `yaml:"cookie,omitempty"`
	Body   any               `yaml:"body,omitempty"`

	IgnoreParent bool `yaml:"ignore_parent,omitempty"`
}

type RequestResult

type RequestResult struct {
	Header map[string]string `yaml:"header,omitempty"`
	Body   string            `yaml:"body,omitempty"`
}

func (*RequestResult) Copy

func (r *RequestResult) Copy(request http.Request)

func (*RequestResult) SetBody

func (r *RequestResult) SetBody(v any)

type Response

type Response struct {
	Header map[string]string `yaml:"header,omitempty"`
	Cookie map[string]string `yaml:"cookie,omitempty"`
	Body   []byte            `yaml:"body,omitempty"`

	StatusCode int    `yaml:"status_code,omitempty"`
	Status     string `yaml:"status,omitempty"`
}

type ResponseResult

type ResponseResult struct {
	Header map[string]string `yaml:"header,omitempty"`
	Body   string            `yaml:"body,omitempty"`
}

func (*ResponseResult) Copy

func (r *ResponseResult) Copy(response http.Response)

func (*ResponseResult) SetBody

func (r *ResponseResult) SetBody(v any)

type Variables

type Variables map[string]any

Jump to

Keyboard shortcuts

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