context

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssignRepository

func AssignRepository() macaron.Handler

AssignRepository to context

func AssignUser

func AssignUser() macaron.Handler

AssignUser to context

func CheckRepoExpiry

func CheckRepoExpiry() macaron.Handler

CheckRepoExpiry and handle

func Contexter

func Contexter() macaron.Handler

Contexter initializes a classic context for a request.

func GitUACheck

func GitUACheck() macaron.Handler

GitUACheck User Agent check

func Toggle

func Toggle(options *ToggleOptions) macaron.Handler

Toggle options

Types

type Context

type Context struct {
	*macaron.Context
	Cache cache.Cache

	Flash   *session.Flash
	Session session.Store

	User  *models.User // logged in user
	Gitxt *Gitxt

	RepoOwnerUsername string

	IsLogged    bool
	IsBasicAuth bool
	// contains filtered or unexported fields
}

Context represents context of a request.

func (*Context) HTML

func (c *Context) HTML(status int, name string)

HTML responses template with given status.

func (*Context) Handle

func (c *Context) Handle(status int, title string, err error)

Handle handles and logs error by given status.

func (*Context) HandleText

func (c *Context) HandleText(status int, title string)

HandleText only

func (*Context) HasError

func (c *Context) HasError() bool

HasError returns true if error occurs in form validation.

func (*Context) JSONSuccess

func (c *Context) JSONSuccess(data interface{})

JSONSuccess responses JSON with status http.StatusOK.

func (*Context) NotFound

func (c *Context) NotFound()

NotFound renders the 404 page.

func (*Context) NotFoundOrServerError

func (c *Context) NotFoundOrServerError(title string, errck func(error) bool, err error)

NotFoundOrServerError use error check function to determine if the error is about not found. It responses with 404 status code for not found error, or error context description for logging purpose of 500 server error.

func (*Context) PageIs

func (c *Context) PageIs(name string)

PageIs sets "PageIsxxx" field in template data.

func (*Context) RenderWithErr

func (c *Context) RenderWithErr(msg, tpl string, f interface{})

RenderWithErr used for page has form validation but need to prompt error to users.

func (*Context) ServeContent

func (c *Context) ServeContent(name string, r io.ReadSeeker, params ...interface{})

ServeContent headers

func (*Context) ServeContentNoDownload

func (c *Context) ServeContentNoDownload(name string, mime string, r io.ReadSeeker, params ...interface{})

ServeContentNoDownload headers

func (*Context) ServerError

func (c *Context) ServerError(title string, err error)

ServerError renders the 500 page.

func (*Context) SubURLRedirect

func (c *Context) SubURLRedirect(location string, status ...int)

SubURLRedirect responses redirection with given location and status. It prepends setting.AppSubURL to the location string.

func (*Context) Success

func (c *Context) Success(name string)

Success responses template with status http.StatusOK.

func (*Context) Title

func (c *Context) Title(locale string)

Title sets "Title" field in template data.

type Gitxt

type Gitxt struct {
	User     *models.User
	Gitxt    *models.Gitxt
	Owner    bool // Gitxt.Owner: "toto/repos" does "repos" belongs to "toto" ?
	UserName string
}

Gitxt struct

type ToggleOptions

type ToggleOptions struct {
	SignInRequired  bool
	SignOutRequired bool
	AdminRequired   bool
	DisableCSRF     bool
	AnonymousCreate bool
}

ToggleOptions struct

Jump to

Keyboard shortcuts

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