~mendelmaleh/dummy

78668a8994abdf17a9d810d2d56ab6b2872e1e34 — Mendel E 1 year, 1 month ago 09d54c3
minimalserver: limit to 8 connections, 2 glyph cache entries
1 files changed, 15 insertions(+), 4 deletions(-)

M cmd/minimalserver/main.go
M cmd/minimalserver/main.go => cmd/minimalserver/main.go +15 -4
@@ 7,13 7,16 @@ import (
	"image/png"
	"io/ioutil"
	"log"
	"net"
	"net/http"
	"runtime"
	"strings"

	"github.com/golang/freetype"
	"github.com/golang/freetype/truetype"
	"golang.org/x/image/font"
	"golang.org/x/image/math/fixed"
	"golang.org/x/net/netutil"
)

type Options struct {


@@ 62,9 65,10 @@ func main() {
		// text
		if len(strings.TrimSpace(opt.Text)) > 0 {
			face := truetype.NewFace(opt.Font, &truetype.Options{
				Size:    opt.Size,
				DPI:     opt.DPI,
				Hinting: font.HintingNone,
				Size:              opt.Size,
				DPI:               opt.DPI,
				Hinting:           font.HintingNone,
				GlyphCacheEntries: 2,
			})

			drawer := &font.Drawer{


@@ 85,7 89,14 @@ func main() {
		}

		png.Encode(w, im)
		runtime.GC()
	})

	log.Panic(http.ListenAndServe(":8080", nil))
	listener, err := net.Listen("tcp", ":8080")
	if err != nil {
		log.Fatal(err)
	}

	listener = netutil.LimitListener(listener, 8)
	log.Panic(http.Serve(listener, nil))
}