Documentation ¶
Index ¶
- Constants
- type Cookie
- type Cookies
- type Handler
- type Opts
- type Request
- func (r *Request) Accept() string
- func (r *Request) AcceptEncoding() string
- func (r *Request) AcceptLanguage() string
- func (r *Request) Connection() string
- func (r *Request) ContentLength() int
- func (r *Request) ContentType() string
- func (r *Request) HTTPType() string
- func (r *Request) Host() string
- func (r *Request) Method() string
- func (r *Request) Path() string
- func (r *Request) UserAgent() string
- type Response
- type TLSPair
- type Webworkers
Constants ¶
const ( // StatusOK represents the "OK" status StatusOK = 200 // StatusCreated represents the "Created" status StatusCreated = 201 // StatusAccepted represents the "Accepted" status StatusAccepted = 202 // StatusNoContent represents the "No Content" status StatusNoContent = 204 // StatusResetContent represents the "Reset Content" status StatusResetContent = 205 // StatusPartialContent represents the "Partial Content" status StatusPartialContent = 206 )
Successful 2xx This class of status code indicates that the client's request was successfully received, understood, and accepted.
const ( // StatusMovedPerminantly represents the "Multiple Choices" status StatusMultipleChoices = 300 // StatusMovedPerminantly represents the "Moved Perminantly" status StatusMovedPerminantly = 301 // StatusFound represents the "Found" status StatusFound = 302 // StatusSeeOther represents the "See Other" status StatusSeeOther = 303 // StatusNotModified represents the "Not Modified" status StatusNotModified = 304 // StatusUseProxy represents the "Use Proxy" status StatusUseProxy = 306 // StatusMovedTemporarily represents the "Moved Temporarily" status StatusMovedTemporarily = 307 )
Redirection 3xx This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request.
const ( // StatusBadRequest represents the "Bad Request" status StatusBadRequest = 400 StatusUnauthorized = 401 // StatusPaymentRequired represents the "Payment Required" status StatusPaymentRequired = 402 // StatusForbidden represents the "Forbidden" status StatusForbidden = 403 // StatusNotFound represents the "Not Found" status StatusNotFound = 404 // StatusMethodNotAllowed represents the "Method Not Allowed" status StatusMethodNotAllowed = 405 // StatusNotAcceptable represents the "Not Acceptable" status StatusNotAcceptable = 406 // StatusProxyAuthRequired represents the "Proxy Authentication Required" status StatusProxyAuthRequired = 407 // StatusRequestTimeout represents the "Request Timeout" status StatusRequestTimeout = 408 // StatusConflict represents the "Conflict" status StatusConflict = 409 // StatusLengthRequired represents "Lenght Required" status StatusLengthRequired = 411 // StatusRequestEntityTooLarge represents the "Request Entity Too Large" status StatusRequestEntityTooLarge = 413 // StatusRequestURITooLong represents the "Request-URI Too Long" status StatusRequestURITooLong = 414 // StatusUnsupportedMediaType represents the "Unsupported Media Type" status StatusUnsupportedMediaType = 415 // StatusExpectationFailed represents the "Expectation Failed" status StatusExpectationFailed = 417 // StatusTeapot represents when a server is a tea pot.. short and stout. StatusTeapot = 418 )
Client Error 4xx This class of status code is intended for cases in which the client seems to have erred.
const ( // StatusInternalServerError represents the "Internal Server Error" status StatusInternalServerError = 500 // StatusNotImplemented represents the "Not Implemented" status StatusNotImplemented = 501 // StatusBadGateway represents the "Bad Gateway" status StatusBadGateway = 502 StatusServiceUnavailable = 503 // StatusGatewayTimeout represents the "Gateway Timeout" status StatusGatewayTimeout = 504 // StatusHTTPVersionUnsupported represents the "HTTP Version Unsupported" status StatusHTTPVersionUnsupported = 505 )
Server Error 5xx This class of status code is intended for cases in which the server is aware that it has erred or is incapable of performing the request.
const ( // ErrEmptyWorkers is returned when workerCap is set to 0 (or ignored) ErrEmptyWorkers = errors.Error("worker capacity must be greater than zero") // ErrEmptyQueue is returned when queueLen is set to 0 (or ignored) ErrEmptyQueue = errors.Error("queue length must be greater than zero") // ErrIsListening is returned when Listen() is called on an instance of webWorkers already listening ErrIsListening = errors.Error("cannot listen on an instance already listening") // ErrIsClosed is returned when an action is attempted on a closed instance ErrIsClosed = errors.Error("cannot perform action on closed instance") // ErrHeadersSent is returned when header modifications are attempted after the headers have already been sent ErrHeadersSent = errors.Error("headers already sent") // ErrEmptyCerts is returned when no certificates are available and the TLS setting is enabled ErrEmptyCerts = errors.Error("number of certificates must be greater than zero if TLS is enabled") // ErrEmptyAddress is returned when an empty address is provided ErrEmptyAddress = errors.Error("address cannot be empty") // ErrInvalidHeaderStatus is returned when an invalid header status is provided ErrInvalidHeaderStatus = errors.Error("invalid header status") // ErrInvalidStatusCode is returned when an invalid status code is provided ErrInvalidStatusCode = errors.Error("invalid status code") )
const ( // ContentTypeHTML is the html content type ContentTypeHTML = "text/html" // ContentTypeJS is the javascript content type ContentTypeJS = "application/js" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cookies ¶
type Cookies struct {
// contains filtered or unexported fields
}
Cookies represents of a set of cookies
func (*Cookies) Dup ¶
Dup will return a copy of the Cookies, so it can be used after the HTTP request/response process has completed
type Opts ¶
type Opts struct { // Number of workers (Note: will maintain a running goroutine for each worker) WorkerCap int `ini:"workerCap"` // Length of requests queue (IE: Requests sitting in memory, rather than waiting on disk using epoll/kqueue) QueueLen int `ini:"queueLen"` // Address to be serving from // TODO: Consider changing this to port, and making it a uint16 Address string `ini:"address"` // Whether or not TLS is enabled TLS bool `ini:"tls"` // List of TLS certifications (Only needed if TLS is set to true) Certs []TLSPair ErrorOutput io.Writer }
Opts are the options used to configure an instance of web workers
func NewOpts ¶
NewOpts returns new options given a provided source Please see the go-ini/ini docu (https://godoc.org/github.com/go-ini/ini#Load) for more information on the source argument
type Request ¶
Request is an HTTP request
func (*Request) AcceptEncoding ¶
AcceptEncoding will return the accept encoding
func (*Request) AcceptLanguage ¶
AcceptLanguage will return the accept language
func (*Request) Connection ¶
Connection will return the connection
func (*Request) ContentLength ¶
ContentLength will return the content length
func (*Request) ContentType ¶
ContentType will return the content type
type Response ¶
type Response struct { Cookies *Cookies // contains filtered or unexported fields }
Response is an http response
func (*Response) ContentType ¶
ContentType will set the content type
func (*Response) StatusCode ¶
StatusCode will set the status code
type Webworkers ¶
type Webworkers struct {
// contains filtered or unexported fields
}
Webworkers is the manager the web workers service
func New ¶
func New(o Opts, fn Handler) (ww *Webworkers, err error)
New returns a new instance of Webworkers
func (*Webworkers) Close ¶
func (ww *Webworkers) Close() (err error)
Close will close an instance of web workers
func (*Webworkers) Listen ¶
func (ww *Webworkers) Listen() (err error)
Listen will begin the listening loop