Documentation
¶
Index ¶
- Constants
- Variables
- func CloseServer() error
- func DoHandle(w http.ResponseWriter, r *http.Request)
- func ListHost() []string
- func Load() error
- func LoadCommonResponseHeader(config *Config)
- func LoadHost(config *Config)
- func LoadMockServiceInfo(config *Config)
- func LoadResponseFile(url string, method string) ([]string, error)
- func LoadResponseHeader(config *Config)
- func MockService()
- func MockServiceCommand()
- func Notify(message string)
- func NotifyAddMockServiceInfo(info interface{})
- func OutRequest(url string, method string, header http.Header, body string)
- func OutResponseBody(method string, url string, isJSON bool, body []byte)
- func OutResponseHeader(mHeader map[string]http.Header)
- func OutputHost(config Config, hostSlice []string) error
- func OutputMockServiceInfo(config Config, infoSlice []MockServiceInfo) error
- func RenameResponseFile(responseFile string, fileName string) error
- func SaveHost() error
- func SaveMockServiceInfo() error
- func SetDefaultTargetHost(targetHost string) bool
- func UpdateAllMockServiceInfo(newInfoSlice []MockServiceInfo)
- func UpdateMockServiceInfo(info MockServiceInfo)
- type Config
- type MockServiceInfo
- type ResponseHeader
Constants ¶
View Source
const ConfigFile = "config.yml"
/ 配置文件
Variables ¶
View Source
var Channel *plugin.MethodChannel
/ 指向go-flutter的Plugin 用于向Flutter端发送消息
Functions ¶
func LoadResponseFile ¶
/ 获取URL的响应文件列表
func LoadResponseHeader ¶
func LoadResponseHeader(config *Config)
/ 读取响应头信息 / 使用代理转发请求时,会自动生成URI对应的响应头信息
func NotifyAddMockServiceInfo ¶
func NotifyAddMockServiceInfo(info interface{})
/ 向Flutter发送通知,添加新的模拟服务信息
func OutRequest ¶
/ 输出请求到文件
func OutResponseBody ¶
/ 输出响应体到文件
func OutputMockServiceInfo ¶
func OutputMockServiceInfo(config Config, infoSlice []MockServiceInfo) error
/ 保存模拟服务信息
func RenameResponseFile ¶
/ 保存目标主机
func UpdateAllMockServiceInfo ¶
func UpdateAllMockServiceInfo(newInfoSlice []MockServiceInfo)
/ 更新单个模拟服务信息和URL对应模拟服务信息Map
func UpdateMockServiceInfo ¶
func UpdateMockServiceInfo(info MockServiceInfo)
/ 更新单个模拟服务信息和URL对应模拟服务信息Map
Types ¶
type Config ¶
type Config struct { Port string `yaml:"port"` // 端口 LogFile string `yaml:"logFile"` // 日志文件 LogLevel int `yaml:"logLevel"` // 日志等级 HostFile string `yaml:"hostFile"` // 目标主机文件 InfoFile string `yaml:"infoFile"` // 模拟服务信息文件 // 使用模拟服务通用响应头 // 仅当URL对应的响应头不存在时使用 UseMockCommonResponseHeader bool `yaml:"useMockCommonResponseHeader"` }
/ 配置
type MockServiceInfo ¶
type MockServiceInfo struct { URL string `yaml:"url" json:"url"` // URL Method string `yaml:"method" json:"method"` // HTTP请求方法 TargetHost string `yaml:"targetHost" json:"targetHost"` // 目标主机 UseDefaultTargetHost bool `yaml:"useDefaultTargetHost" json:"useDefaultTargetHost"` // 使用默认目标主机 UseMockService bool `yaml:"useMockService" json:"useMockService"` // 使用模拟服务 StatusCode int `yaml:"statusCode" json:"statusCode"` // 响应状态码 ResponseFile string `yaml:"responseFile" json:"responseFile"` // 响应文件 Description string `yaml:"description" json:"description"` // 说明 }
/ 模拟服务信息
Click to show internal directories.
Click to hide internal directories.