rest

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2019 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RestPathPrefix = ""

RestPathPrefix is a prefix you can use in front of all goradd rest paths, like a directory path, to indicate that this is a goradd rest path.

Functions

func HandleRequest

func HandleRequest(w http.ResponseWriter, r *http.Request) bool

func Redirect

func Redirect(url string)

Redirect aborts the current page load and tells the browser to load a different url.

func RegisterPath

func RegisterPath(path string, handler RestPathHandler)

RegisterPath associates the given URL path with the given creation function. Call this from an init() function. Afterwards, whenever a user navigates to the given path, the result of the query will be presented to the user.

Types

type HttpError

type HttpError struct {
	// contains filtered or unexported fields
}

HttpError represents an error response to a http request.

func (*HttpError) Send

func (e *HttpError) Send(errCode int)

Send will cause the page to error with the given http error code.

func (*HttpError) SetResponseHeader

func (e *HttpError) SetResponseHeader(key, value string)

SetResponseHeader sets a key-value in the header response.

type RestManager

type RestManager struct {
	// contains filtered or unexported fields
}

The RestManager is a singleton global that manages the registration and deployment of rest paths. It acts like a URL router, returning the RestPathHandler that corresponds to a particular URL path. init() functions should be created for each path that associates a function to create a rest path, with the URL that corresponds to the path.

func GetRestManager

func GetRestManager() *RestManager

GetRestManager returns the current page manager.

type RestManagerI

type RestManagerI interface {
	RegisterPath(path string, creationFunction RestPathHandler)
}

type RestPathHandler

type RestPathHandler func(ctx context.Context, buf *bytes.Buffer) error

Jump to

Keyboard shortcuts

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