mirror of
https://github.com/yusing/godoxy.git
synced 2026-01-11 22:30:47 +01:00
- Updated dev.compose.yml to define a new bench service that serves 4096 bytes of random data. - Modified configurations for Traefik, Caddy, and Nginx to route traffic to the new bench service. - Added Dockerfile and Go application for the bench server, including necessary Go modules. - Updated benchmark script to target the new bench service endpoint.
35 lines
657 B
Go
35 lines
657 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
"math/rand/v2"
|
|
)
|
|
|
|
var printables = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
|
var random = make([]byte, 4096)
|
|
|
|
func init() {
|
|
for i := range random {
|
|
random[i] = printables[rand.IntN(len(printables))]
|
|
}
|
|
}
|
|
|
|
func main() {
|
|
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
w.WriteHeader(http.StatusOK)
|
|
w.Write(random)
|
|
})
|
|
|
|
server := &http.Server{
|
|
Addr: ":80",
|
|
Handler: handler,
|
|
}
|
|
|
|
log.Println("Bench server listening on :80")
|
|
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
|
log.Fatalf("ListenAndServe: %v", err)
|
|
}
|
|
}
|