system

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2017 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CSRFCookie = "XSRF-TOKEN"
	CSRFHeader = "X-XSRF-TOKEN"
	CSRFKey    = "csrf_token"
)

CSRF token constants

Variables

This section is empty.

Functions

func APIInvalidHandler

func APIInvalidHandler(w http.ResponseWriter, _ *http.Request)

APIInvalidHandler responds to invalid requests. It matches the signature of http.HanderFunc.

func DisableLog

func DisableLog()

DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.

func GojiWebHandlerFunc

func GojiWebHandlerFunc(h http.HandlerFunc) web.HandlerFunc

GojiWebHandlerFunc is an adaptor that allows an http.HanderFunc where a web.HandlerFunc is required.

func ReloadTemplatesSig

func ReloadTemplatesSig(app *Application)

func UseLogger

func UseLogger(logger btclog.Logger)

UseLogger uses a specified Logger to output package logging info. This should be used in preference to SetLogWriter if the caller is also using btclog.

func WriteAPIResponse

func WriteAPIResponse(resp *APIResponse, code int, w http.ResponseWriter)

WriteAPIResponse marshals the given poolapi.Response into the http.ResponseWriter and sets HTTP status code.

Types

type APIResponse

type APIResponse struct {
	Status  string      `json:"status"`
	Code    codes.Code  `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data,omitempty"`
}

APIResponse is the response struct used by the server to marshal to a JSON object. Data should be another struct with JSON tags.

func NewAPIResponse

func NewAPIResponse(status string, code codes.Code, message string, data interface{}) *APIResponse

NewAPIResponse is a constructor for APIResponse.

type Application

type Application struct {
	APISecret      string
	Template       *template.Template
	TemplatesPath  string
	Store          *sessions.CookieStore
	DbMap          *gorp.DbMap
	CsrfProtection *CsrfProtection
}

func (*Application) APIHandler

func (application *Application) APIHandler(apiFun func(web.C, *http.Request) *APIResponse) web.HandlerFunc

APIHandler executes an API processing function that provides an *APIResponse required by WriteAPIResponse. It returns an web.HandlerFunc so it can be used with a goji router.

func (*Application) ApplyAPI

func (application *Application) ApplyAPI(c *web.C, h http.Handler) http.Handler

func (*Application) ApplyAuth

func (application *Application) ApplyAuth(c *web.C, h http.Handler) http.Handler

func (*Application) ApplyCsrfProtection

func (application *Application) ApplyCsrfProtection(c *web.C, h http.Handler) http.Handler

func (*Application) ApplyDbMap

func (application *Application) ApplyDbMap(c *web.C, h http.Handler) http.Handler

func (*Application) ApplyGzip

func (application *Application) ApplyGzip(c *web.C, h http.Handler) http.Handler

func (*Application) ApplyIsXhr

func (application *Application) ApplyIsXhr(c *web.C, h http.Handler) http.Handler

func (*Application) ApplySessions

func (application *Application) ApplySessions(c *web.C, h http.Handler) http.Handler

Makes sure controllers can have access to session

func (*Application) ApplyTemplates

func (application *Application) ApplyTemplates(c *web.C, h http.Handler) http.Handler

Makes sure templates are stored in the context

func (*Application) Close

func (application *Application) Close()

func (*Application) Init

func (application *Application) Init(APISecret string, baseURL string,
	cookieSecret string, cookieSecure bool, DBHost string, DBName string,
	DBPassword string,
	DBPort string, DBUser string)

func (*Application) LoadTemplates

func (application *Application) LoadTemplates(templatePath string) error

func (*Application) Route

func (application *Application) Route(controller interface{}, route string) web.HandlerFunc

type Controller

type Controller struct {
}

func (*Controller) GetDbMap

func (controller *Controller) GetDbMap(c web.C) *gorp.DbMap

func (*Controller) GetSession

func (controller *Controller) GetSession(c web.C) *sessions.Session

func (*Controller) GetTemplate

func (controller *Controller) GetTemplate(c web.C) *template.Template

func (*Controller) IsXhr

func (controller *Controller) IsXhr(c web.C) bool

func (*Controller) Parse

func (controller *Controller) Parse(t *template.Template, name string, data interface{}) string

type CsrfProtection

type CsrfProtection struct {
	Key    string
	Cookie string
	Header string
	Secure bool
}

Jump to

Keyboard shortcuts

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