Дмитрий
2 years ago
2 changed files with 62 additions and 6 deletions
@ -1,19 +1,39 @@ |
|||||||
|
# port for main server
|
||||||
|
port := 5053
|
||||||
|
moc_server_address := 127.0.0.1:5059
|
||||||
|
|
||||||
run: |
run: |
||||||
go run cmd/main.go -p 5053 -d "127.0.0.1:5059"
|
go run cmd/main.go -p $(port) -d "$(moc_server_address)"
|
||||||
|
|
||||||
test-ip: |
test-ip: |
||||||
go run cmd/main.go -p 5053 -d "127.0.0.1:5059,localhost:5059"
|
go run cmd/main.go -p $(port) -d "$(moc_server_address),localhost:5059"
|
||||||
|
|
||||||
test-port: |
test-port: |
||||||
go run cmd/main.go -p 5053 -d "127.0.0.1:5059,127.0.0.1:as"
|
go run cmd/main.go -p $(port) -d "$(moc_server_address),127.0.0.1:as"
|
||||||
|
|
||||||
test-port-max: |
test-port-max: |
||||||
go run cmd/main.go -p 5053 -d "127.0.0.1:5059,127.0.0.1:65537"
|
go run cmd/main.go -p $(port) -d "$(moc_server_address),127.0.0.1:65537"
|
||||||
|
|
||||||
test-port-endpoint: |
test-port-endpoint: |
||||||
go run cmd/main.go -p 5053 -d "127.0.0.1:9001/bid_request"
|
go run cmd/main.go -p $(port) -d "127.0.0.1:9001/bid_request"
|
||||||
|
|
||||||
build: |
build: |
||||||
go build -o bin/simple-choose-ad cmd/main.go
|
go build -o bin/simple-choose-ad cmd/main.go
|
||||||
|
|
||||||
tests: |
start-moc-server: |
||||||
|
@echo "[!] Starting moc server on 127.0.0.1:5059..."
|
||||||
|
@nohup go run internal/moc_server.go> /dev/null 2>&1 & echo $! > run.pid
|
||||||
|
|
||||||
|
stop-moc-server: |
||||||
|
@echo "[!] Killing moc server"
|
||||||
|
@cat run.pid | xargs kill -9
|
||||||
|
@rm run.pid
|
||||||
|
|
||||||
|
test-server: |
||||||
|
@echo "Testing server..."
|
||||||
|
@cd "cmd/client_server/"; \
|
||||||
|
go test
|
||||||
|
|
||||||
|
tests: start-moc-server |
||||||
|
@$(MAKE) test-server
|
||||||
|
@$(MAKE) stop-moc-server
|
||||||
|
@ -0,0 +1,36 @@ |
|||||||
|
package main |
||||||
|
|
||||||
|
import ( |
||||||
|
"io/ioutil" |
||||||
|
"log" |
||||||
|
"net/http" |
||||||
|
) |
||||||
|
|
||||||
|
func main() { |
||||||
|
vres := `{ |
||||||
|
"id": "123", |
||||||
|
"imp": [{ |
||||||
|
"id": 123, |
||||||
|
"width": 144, |
||||||
|
"height": 122, |
||||||
|
"title": "Title1", |
||||||
|
"url": "example.com", |
||||||
|
"price": 123.5 |
||||||
|
},{ |
||||||
|
"id": 123, |
||||||
|
"width": 155, |
||||||
|
"height": 133, |
||||||
|
"title": "Title2", |
||||||
|
"url": "upachka.com", |
||||||
|
"price": 143.5 |
||||||
|
}]}` |
||||||
|
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { |
||||||
|
b, _ := ioutil.ReadAll(r.Body) |
||||||
|
log.Println(string(b)) |
||||||
|
// as, err := json.Marshal(vres)
|
||||||
|
|
||||||
|
w.Header().Add("Content-Type", "application/json") |
||||||
|
w.Write([]byte(vres)) |
||||||
|
}) |
||||||
|
log.Fatal(http.ListenAndServe("127.0.0.1:5059", nil)) |
||||||
|
} |
Loading…
Reference in new issue