{"modulePath":"github.com/xaionaro-go/picapi","version":"v0.0.0-20190907075849-7f3e19902875","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package httpserver\n\n## Variables\n\n```go\nvar (\n\t// ErrAlreadyStarted is returned when method `Start` is called on an already started `HTTPServer`.\n\tErrAlreadyStarted = errors.New(`already started`)\n\n\t// ErrNotStarted is returned when method `Stop` is called on a non-started-yet `HTTPServer`.\n\tErrNotStarted = errors.New(`not started`)\n\n\t// ErrImageProcessorIsRequireed is returned when NewHTTPServer is called with nil `proc`.\n\tErrImageProcessorIsRequireed = errors.New(`image processor is required`)\n)\n```\n\n## Types\n\n```go\ntype ErrBadGateway struct {\n\tMessage string\n}\n```\nErrBadGateway is an error which will be returned to a browser with as a \"Bad Gateway\" error\n\n```go\nfunc (err *ErrBadGateway) Error() string\n```\nError just implements interface \\`error\\`.\n\n```go\ntype ErrBadRequest struct {\n\tMessage string\n}\n```\nErrBadRequest is an error which will be returned to a browser with as a \"Bad Request\" error\n\n```go\nfunc (err *ErrBadRequest) Error() string\n```\nError just implements interface \\`error\\`.\n\n```go\ntype ErrForbidden struct {\n\tMessage string\n}\n```\nErrForbidden is an error which will be returned to a browser with as a \"Forbidden\" error\n\n```go\nfunc (err *ErrForbidden) Error() string\n```\nError just implements interface \\`error\\`.\n\n```go\ntype HTTPServer struct {\n\n\t// ImageProcessor is the implementation of image manipulation tool\n\tImageProcessor imageprocessor.ImageProcessor\n\t// contains filtered or unexported fields\n}\n```\nHTTPServer is the implemention of an HTTP server which implements \\`picapi\\`'s methods\n\n```go\nfunc NewHTTPServer(\n\tproc imageprocessor.ImageProcessor,\n\taccessLogger Printfer,\n\thandlerLogger Printfer,\n\tcacheDuration time.Duration,\n\tcacheMaxEntries uint64,\n\tcacheMaxEntrySize uint64,\n) (srv *HTTPServer, err error)\n```\nNewHTTPServer returns a new instance of \\`HTTPServer\\`.\n\n\\`HTTPServer\\` will not be started automatically. It's required to call method \\`Start\\` to start it.\n\n\\`accessLogger\\` is used to log requests (similar to an \"access.log\").\n\n\\`handlerLogger\\` is used to log errors and warnings by handlers (similar to \"error.log\")\n\n```go\nfunc (srv *HTTPServer) Done() \u003c-chan struct{}\n```\nDone returns the \\`Done()\\` of the context of the HTTPServer instance.\n\n```go\nfunc (srv *HTTPServer) Start(\n\tctx context.Context,\n\tlistenAddress string,\n) (err error)\n```\nStart creates a listener and starts the process of serving incoming HTTP requests.\n\n```go\nfunc (srv *HTTPServer) Stop() (err error)\n```\nStop is anti-Start: it stops the process of serving incoming HTTP requsts and closes the listener.\n\n```go\nfunc (srv *HTTPServer) Wait() error\n```\nWait waits for HTTP server to stop\n\n```go\ntype Printfer interface {\n\t// Printf is a pretty-standart `Printf` (`fmt` is the format and `args` are the arguments for the format).\n\t//\n\t// For example you can use `log.New` as `Printfer`.\n\tPrintf(fmt string, args ...interface{})\n}\n```\nPrintfer is a simple logger interface for \\`NewHTTPServer\\`\n\n","path":"github.com/xaionaro-go/picapi/httpserver","name":"httpserver","synopsis":"","isRedistributable":true}
