gosp: github.com/spakin/gosp/src/gosp Index | Files

package gosp

import "github.com/spakin/gosp/src/gosp"

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.


Package Files


func Fprintf Uses

func Fprintf(w Writer, format string, a ...interface{}) (n int, err error)

Fprintf is merely a renamed fmt.Fprintf.

func LiesInOrBelow Uses

func LiesInOrBelow(child, parent string) (bool, error)

LiesInOrBelow returns true if a child file or directory lies in or below a parent directory (or is the parent directory).

func LogDebugMessage Uses

func LogDebugMessage(ch Metadata, m string)

LogDebugMessage asks the Web server to write a debug message to its log file.

func Open Uses

func Open(name string) (*os.File, error)

Open is a wrapper for os.Open that allows opening only those files that lie within or below the current directory.

func ReportPanic Uses

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 Uses

func SetHTTPStatus(ch Metadata, s int)

SetHTTPStatus tells the Web server what HTTP status code it should return.

func SetHeaderField Uses

func SetHeaderField(ch Metadata, k, v string, repl bool)

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 Uses

func SetMIMEType(ch Metadata, mt string)

SetMIMEType tells the Web server what MIME type it should return.

type KeyValue Uses

type KeyValue struct {
    Key   string
    Value string

KeyValue represents a metadata key:value pair.

type Metadata Uses

type Metadata chan<- KeyValue

Metadata is a channel on which we can send HTTP metadata.

type RequestData Uses

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.

type Writer Uses

type Writer interface {

Writer is merely a renamed io.Writer.

Package gosp imports 8 packages (graph). Updated 2019-12-01. Refresh now. Tools for package owners.