Documentation
¶
Overview ¶
Package gosp provides all of the types, functions, and values needed to compile a generated Gosp server. RequestData, Open, and perhaps LiesInOrBelow are the only things defined by this package that an end user should care about. Everything else is used internally by the Gosp server.
Index ¶
- func Fprintf(w Writer, format string, a ...interface{}) (n int, err error)
- func LiesInOrBelow(child, parent string) (bool, error)
- func LogDebugMessage(ch Metadata, m string)
- func Open(name string) (*os.File, error)
- func ReportPanic(r interface{}, ch Metadata)
- func SetHTTPStatus(ch Metadata, s int)
- func SetHeaderField(ch Metadata, k, v string, repl bool)
- func SetMIMEType(ch Metadata, mt string)
- type KeyValue
- type Metadata
- type RequestData
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LiesInOrBelow ¶
LiesInOrBelow returns true if a child file or directory lies in or below a parent directory (or is the parent directory).
func LogDebugMessage ¶
LogDebugMessage asks the Web server to write a debug message to its log file.
func Open ¶
Open is a wrapper for os.Open that allows opening only those files that lie within or below the current directory.
func ReportPanic ¶
func ReportPanic(r interface{}, ch Metadata)
ReportPanic alerts the Web server that the Gosp server encountered an unexpected error. It should be called from a deferred function in GospGeneratePage.
func SetHTTPStatus ¶
SetHTTPStatus tells the Web server what HTTP status code it should return.
func SetHeaderField ¶
SetHeaderField provides a field name and value for the Web server to include in the HTTP header. If repl is true, the value replaces any prior value for the field. If repl is false, the field and value are appended to the existing set of {field name, value} pairs.
func SetMIMEType ¶
SetMIMEType tells the Web server what MIME type it should return.
Types ¶
type Metadata ¶
type Metadata chan<- KeyValue
Metadata is a channel on which we can send HTTP metadata.
type RequestData ¶
type RequestData struct { Scheme string // HTTP scheme ("http" or "https") LocalHostname string // Name of the local host Port int // Port number to which the request was issued URI string // Path portion of the URI PathInfo string // Additional text following the Gosp filename QueryArgs string // Query arguments from the request URL string // Complete URL requested Method string // Request method ("GET", "POST", etc.) RequestLine string // First line of the request (e.g., "GET / HTTP/1.1") RequestTime int64 // Request time in nanoseconds since the Unix epoch RemoteHostname string // Name of the remote host RemoteIP string // IP address of the remote host Filename string // Local filename of the Gosp page PostData map[string]string // {Key, value} pairs sent by a POST request GetData map[string]string // {Key, value} pairs sent by a GET request (parsed version of QueryArgs) HeaderData map[string]string // Request headers as {key, value} pairs AdminEmail string // Email address of the Web server administrator Environment map[string]string // Environment variables passed in from the server }
RequestData encapsulates Web-server information passed into a Gosp server. Many of its fields come from the client. Those should therefore not be used without first checking them for invalid or malicious content.