gosp

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2019 License: BSD-3-Clause-Clear Imports: 8 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fprintf

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

Fprintf is merely a renamed fmt.Fprintf.

func LiesInOrBelow

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

func LogDebugMessage(ch Metadata, m string)

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

func Open

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

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

func SetHTTPStatus(ch Metadata, s int)

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

func SetHeaderField

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

func SetMIMEType(ch Metadata, mt string)

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

Types

type KeyValue

type KeyValue struct {
	Key   string
	Value string
}

KeyValue represents a metadata key:value pair.

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.

type Writer

type Writer interface {
	io.Writer
}

Writer is merely a renamed io.Writer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL