proxy

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright 2024 Emin Muhammadi

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var MockPatterns = func() []MockPattern {
	patterns := LoadMockPatterns()
	logger.Log.Println("Loaded mock patterns: ", patterns)

	return patterns
}()

Functions

func CreateProxyServer

func CreateProxyServer() *http.Server

func HashSession

func HashSession(ctx *goproxy.ProxyCtx) string

func IsMockPatternMatches

func IsMockPatternMatches(ctx *goproxy.ProxyCtx) bool

func MockRequestHandler

func MockRequestHandler(req *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response)

func MockResponseHandler

func MockResponseHandler(resp *http.Response, ctx *goproxy.ProxyCtx) *http.Response

func RequestHandler

func RequestHandler(req *http.Request, ctx *goproxy.ProxyCtx) (*http.Request, *http.Response)

func ResponseHandler

func ResponseHandler(resp *http.Response, ctx *goproxy.ProxyCtx) *http.Response

func StartProxyServer

func StartProxyServer(server *http.Server)

Types

type MockPattern

type MockPattern struct {
	Method   string       `yaml:"method"`
	Host     string       `yaml:"host"`
	Path     string       `yaml:"path"`
	Response ResponseMock `yaml:"response"`
}

func FindPattern

func FindPattern(ctx *goproxy.ProxyCtx) *MockPattern

func LoadMockPatterns

func LoadMockPatterns() []MockPattern

type PatternConfig

type PatternConfig struct {
	Patterns []MockPattern `yaml:"patterns"`
}

type ResponseMock

type ResponseMock struct {
	StatusCode int    `yaml:"status_code"`
	Headers    string `yaml:"headers"`
	Body       string `yaml:"body"`
}

Jump to

Keyboard shortcuts

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