Documentation
¶
Index ¶
Constants ¶
View Source
const ( GET byte = iota POST PUT DELETE )
View Source
const ( ContentTypeForm = "application/x-www-form-urlencoded" ContentTypeMultipartForm = "multipart/form-data" )
View Source
const ( ContentSizeKey = "CONTENT_LENGTH" ContentTypeKey = "CONTENT_TYPE" RequestMethodKey = "REQUEST_METHOD" RequestUriKey = "REQUEST_URI" DocumentUriKey = "DOCUMENT_URI" DocumentRootKey = "DOCUMENT_ROOT" QueryStringKey = "QUERY_STRING" RemoteAddrKey = "REMOTE_ADDR" RemotePortKey = "REMOTE_PORT" RequestedWithKey = "HTTP_X_REQUESTED_WITH" HttpCookieKey = "HTTP_COOKIE" HttpUpgradeKey = "HTTP_UPGRADE" HttpUserAgentKey = "HTTP_USER_AGENT" )
Variables ¶
View Source
var ( InvalidHeaderErr = errors.New("Invalid header") InvalidContentErr = errors.New("Invalid content size") UnexpectedEndErr = errors.New("Unexpected end of stream") )
View Source
var ( RespTypeHtml = []byte("text/html") RespTypeText = []byte("text/plain") RespTypeJson = []byte("text/json") RespCodeOK = []byte("200 OK") RespCodeNotFound = []byte("404 Not found") RespCodeBadRequest = []byte("400 Bad request") RespCodeInternalError = []byte("500 Internal error") )
View Source
var ( RespNotFound = NewResponse(RespCodeNotFound, RespTypeText, RespCodeNotFound) RespBadRequest = NewResponse(RespCodeBadRequest, RespTypeText, RespCodeBadRequest) RespInternalError = NewResponse(RespCodeInternalError, RespTypeText, RespCodeInternalError) )
Functions ¶
func ReadHeader ¶
Types ¶
type Handler ¶
type Handler struct {
Path string
Func HandlerFunc
}
type HandlerFunc ¶
type Request ¶
type Request struct {
Connection net.Conn
Header http.Header
RawURI string
URL *url.URL
Query url.Values
Form url.Values
Files map[string][]*multipart.FileHeader
MultipartForm *multipart.Form
Cookies []*http.Cookie
Method byte
IsAJAX bool
UserAgent string
Content []byte
ContentType string
ContentSize int64
Settings *Settings // settings used while reading this request
}
type Response ¶
type Response struct {
ResponseCode []byte
ContentType []byte
Content []byte
Cookies []*http.Cookie
Header http.Header
}
func NewResponse ¶
type Server ¶
type Server struct {
Settings *Settings
Handlers []Handler
Close chan bool
WaitGroup sync.WaitGroup
}
func (*Server) AddHandler ¶
func (srv *Server) AddHandler(path string, handler HandlerFunc)
func (*Server) ListenUnix ¶
Click to show internal directories.
Click to hide internal directories.