Initial commit http_proxy
This commit is contained in:
parent
9123d0103d
commit
ac62eab859
3 changed files with 80 additions and 0 deletions
44
pkg/plugins/http_proxy/Makefile
Normal file
44
pkg/plugins/http_proxy/Makefile
Normal file
|
@ -0,0 +1,44 @@
|
|||
VERSION = $(shell git describe --dirty --tags --always)
|
||||
DIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
PKGS = $(shell go list ./...)
|
||||
TEST_PKGS = $(shell find . -type f -name "*_test.go" -printf '%h\n' | sort -u)
|
||||
GOARGS = GOOS=linux GOARCH=amd64
|
||||
GO_BUILD_ARGS = -buildmode=plugin -ldflags="-w -s"
|
||||
GO_CONTAINER_BUILD_ARGS = -buildmode=plugin -ldflags="-w -s" -a -installsuffix cgo
|
||||
GO_DEBUG_BUILD_ARGS = -buildmode=plugin -gcflags "all=-N -l"
|
||||
PLUGIN_NAME = $(shell basename $(DIR)).so
|
||||
OUT_DIR = $(DIR)../../../plugins
|
||||
DEBUG_PORT = 2345
|
||||
|
||||
.PHONY: deps format compile test cli-cover-report html-cover-report
|
||||
|
||||
all: format compile test
|
||||
|
||||
deps:
|
||||
@go mod tidy
|
||||
@go build -buildmode=plugin -v $(DIR)...
|
||||
|
||||
format:
|
||||
@go fmt $(PKGS)
|
||||
|
||||
compile: deps
|
||||
@mkdir -p $(OUT_DIR)
|
||||
ifdef DEBUG
|
||||
@echo 'Compiling for debugging...'
|
||||
@$(GOARGS) go build $(GO_DEBUG_BUILD_ARGS) -o $(OUT_DIR)/$(PLUGIN_NAME) $(DIR)
|
||||
else ifdef CONTAINER
|
||||
@$(GOARGS) go build $(GO_CONTAINER_BUILD_ARGS) -o $(OUT_DIR)/$(PLUGIN_NAME) $(DIR)
|
||||
else
|
||||
@$(GOARGS) go build $(GO_BUILD_ARGS) -o $(OUT_DIR)/$(PLUGIN_NAME) $(DIR)
|
||||
endif
|
||||
|
||||
test:
|
||||
@go test -coverprofile=./cov-raw.out -v $(TEST_PKGS)
|
||||
@cat ./cov-raw.out | grep -v "generated" > ./cov.out
|
||||
@rm -f $(DIR)$(PLUGIN_NAME)
|
||||
|
||||
cli-cover-report:
|
||||
@go tool cover -func=cov.out
|
||||
|
||||
html-cover-report:
|
||||
@go tool cover -html=cov.out -o .coverage.html
|
13
pkg/plugins/http_proxy/init.go
Normal file
13
pkg/plugins/http_proxy/init.go
Normal file
|
@ -0,0 +1,13 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/baez90/inetmock/pkg/logging"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func init() {
|
||||
logger, _ := logging.CreateLogger()
|
||||
logger = logger.With(
|
||||
zap.String("ProtocolHandler", name),
|
||||
)
|
||||
}
|
23
pkg/plugins/http_proxy/main.go
Normal file
23
pkg/plugins/http_proxy/main.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"github.com/baez90/inetmock/internal/config"
|
||||
"go.uber.org/zap"
|
||||
"sync"
|
||||
)
|
||||
|
||||
const (
|
||||
name = "http_proxy"
|
||||
)
|
||||
|
||||
type httpProxy struct {
|
||||
logger *zap.Logger
|
||||
}
|
||||
|
||||
func (h httpProxy) Run(config config.HandlerConfig) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
func (h httpProxy) Shutdown(wg *sync.WaitGroup) {
|
||||
panic("implement me")
|
||||
}
|
Loading…
Reference in a new issue