captcha icon indicating copy to clipboard operation
captcha copied to clipboard

Make Server accept a config struct

Open dchest opened this issue 10 years ago • 0 comments

Currently, Server, accepts imgWidth and imgHeight. I'd like to change it to accept a configuration struct to make it easier to expand it without API change:

type ServerConfig struct {
   ImgWidth  int
   ImgHeight int
}

func Server(config *ServerConfig) http.Handler

Another idea is to make top-level functions methods on config (renamed Server or something):

type Server struct {
   ImgWidth     int
   ImgHeight    int
   Store        Store
   CollectNum   int
   Expiration   time.Time
}

func (c *Server) Handler() http.Handler

dchest avatar Feb 01 '15 08:02 dchest