Documentation ¶
Overview ¶
Package webutil implements some Web utility functions. It also implments a cache mechanism for any file that is to be served via http.
Index ¶
- type HTTP
- func (h *HTTP) AddSuffix(rPath string, fileExtension string) string
- func (h *HTTP) GenerateSessionID(r *http.Request) string
- func (h *HTTP) GetCookie(cname string, r *http.Request) string
- func (h *HTTP) GetMIMEContentType(ext string) string
- func (h *HTTP) IsPortNoValid(portno int) bool
- func (h *HTTP) RemoveCommentsFromBiteArry(b []byte, begin string, end string) []byte
- func (h *HTTP) RemoveCommentsFromByBiteArry(b []byte, begin string, end string) []byte
- func (h *HTTP) RemoveCommentsFromString(s string, begin string, end string) string
- func (h *HTTP) RemoveCookie(cname string, r *http.Request, w http.ResponseWriter) bool
- func (h *HTTP) ServeStaticFile(w http.ResponseWriter, r *http.Request)
- func (h *HTTP) SetContentTypeAndWrite(w http.ResponseWriter, r *http.Request, f []byte) bool
- func (h *HTTP) SetCookie(cname string, cvalue string, maxAge int, w http.ResponseWriter) string
- type UserSession
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTP ¶
HTTP are common http callback functions.
func (*HTTP) AddSuffix ¶
AddSuffix adds file extension (i.e. .html) to the path if not present. It will check for /null in the path (maybe passed by javascript in error). It also adds index.html to the path, if the path is a directory.
func (*HTTP) GenerateSessionID ¶
GenerateSessionID creates a sessionID that is comprised of a double MD5 of caller's IP address and user agent.
func (*HTTP) GetMIMEContentType ¶
GetMIMEContentType first checks the standard extensions i.e. .png, .js,... if not found it uses a custom parsing to return the right content type.
func (*HTTP) IsPortNoValid ¶ added in v1.1.2
IsPortNoValid checks the ragne of an tcp/ip port number.
func (*HTTP) RemoveCommentsFromBiteArry ¶ added in v1.1.2
RemoveCommentsFromByBiteArry removes a block of text from a byte array.
func (*HTTP) RemoveCommentsFromByBiteArry ¶
RemoveCommentsFromByBiteArry removes a block of text from a byte array.
func (*HTTP) RemoveCommentsFromString ¶ added in v1.1.1
RemoveCommentsFromString removes a block of text from inside an string.
func (*HTTP) RemoveCookie ¶
RemoveCookie a cookie by setting its expiration in the past.
func (*HTTP) ServeStaticFile ¶
func (h *HTTP) ServeStaticFile(w http.ResponseWriter, r *http.Request)
ServeStaticFile processes static files for a website. Static files are the ones that require no additional rending before their content is written to a ResponseWrite object, hence no custom error handling, if file is not found. The MIME is written to the Response Header according to the extension of the requested file. Examples are: .js, .css, .html.
func (*HTTP) SetContentTypeAndWrite ¶ added in v1.1.1
SetContentTypeAndWrite writes the response and reutrns false, if mime type not found; returns true if mime type found. It uses the conent passed via an arg rather than than that of the request.