web

package
v0.0.0-...-0cb2a1e Latest Latest
Warning

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

Go to latest
Published: May 16, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	InvalidBody        ErrorType = "INVALID_BODY"
	CannotParsePayload           = "CANNOT_PARSE_PAYLOAD"
	InvalidAccessToken           = "INVALID_ACCESS_TOKEN"
	InvalidName                  = "INVALID_NAME"
	ServerError                  = "SERVER_ERROR"
	Unauthorized                 = "UNAUTHORIZED"
	InvalidEndpoint              = "INVALID_ENDPOINT"
)

Variables

This section is empty.

Functions

func StartWebServer

func StartWebServer()

Types

type ErrorHandler

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

func (ErrorHandler) ServeHTTP

func (h ErrorHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ErrorResponse

type ErrorResponse struct {
	ErrorMessage string    `json:"error_message"`
	ErrorType    ErrorType `json:"error_type"`
}

type ErrorType

type ErrorType string

type LoginRequest

type LoginRequest struct {
	Token string `json:"token"`
	Name  string `json:"name"`
}

type LoginResponse

type LoginResponse struct {
	AccessToken string `json:"access_token"`
}

type SPAHandler

type SPAHandler struct {
	StaticPath string
	IndexPath  string
}

SPAHandler implements the http.Handler interface, so we can use it to respond to HTTP requests. The path to the static directory and path to the index file within that static directory are used to serve the SPA in the given static directory.

func (SPAHandler) ServeHTTP

func (h SPAHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP inspects the URL path to locate a file within the static dir on the SPA handler. If a file is found, it will be served. If not, the file located at the index path on the SPA handler will be served. This is suitable behavior for serving an SPA (single page application).

type User

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

Jump to

Keyboard shortcuts

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