web

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2021 License: GPL-3.0, GPL-3.0-or-later Imports: 30 Imported by: 0

Documentation

Overview

the package web contains the web-related stuff, i.e. all handlers the routing "table" and loads of functions for rendering the views and interacting with the database

Index

Constants

View Source
const STATE_FAILED string = "static/img/build_failed.png"
View Source
const STATE_MISSED string = "static/img/build_miss.png"
View Source
const STATE_PASSED string = "static/img/build_passed.png"

/repo/state/:id return a corresponding image for README files of projects only when the repo is public

Variables

This section is empty.

Functions

func AdminAuthHandler

func AdminAuthHandler(ctx echo.Context) error

/admin/auth list all authentication modules

func AdminAuthInstanceHandler

func AdminAuthInstanceHandler(ctx echo.Context) error

/admin/auth/instance/:id TODO

func AdminAuthInstanceNewHandler

func AdminAuthInstanceNewHandler(ctx echo.Context) error

/admin/auth/instance/new/:name TODO

func AdminInfoHandler

func AdminInfoHandler(ctx echo.Context) error

/admin/info prints some information about the mvoCI server and its dependencies

func ApiTokenFromSession

func ApiTokenFromSession(u *core.User, ctx echo.Context) bool

check that the API token exists

func BuildStatus

func BuildStatus(s string) template.HTML

Returns html-code for the build-status of a repo

func CalcBuildDuration

func CalcBuildDuration(b []core.Build)

calculate the duration of a build from finish and start-time

func ChangeLoginToken

func ChangeLoginToken(ctx echo.Context, u core.User, nextStep string, stepExtra string) bool

update the loginToken to the nextStep, set its extra, generate a new tokenstring and write it to the user

func CollectCookie

func CollectCookie(ctx echo.Context, name string) *http.Cookie

return the http.Cookie for a name or nil if it doesn't exist

func CookieExists

func CookieExists(ctx echo.Context, name string) bool

return whether a cookie exists

func GenerateLoginToken

func GenerateLoginToken(try int) string

try to generate a collision free login token

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func GenerateRandomString

func GenerateRandomString(n int) (string, error)

GenerateRandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.

func HTTPError

func HTTPError(code int, ctx echo.Context) error

returns an HTTP error

func NewAPIToken

func NewAPIToken(l *core.LoginToken, ctx echo.Context, u core.User, name string) bool

generate a new api token from the users settings page

func NewLoginToken

func NewLoginToken(l *core.LoginToken, ctx echo.Context, u core.User, nextStep string, stepExtra string) bool

create a new login token for a given user with nextstep and auth extra

func ReadCookie

func ReadCookie(ctx echo.Context, name string) (string, error)

return the content of a cookie

func RemoveCookie

func RemoveCookie(ctx echo.Context, name string)

remove a cookie from the end users browser

func RemoveLoginToken

func RemoveLoginToken(ctx echo.Context)

remove a login token

func RenderTime

func RenderTime(t time.Time) string

Render time on the website

func SecretCheck

func SecretCheck(data io.Reader, secret string, theirs string, method string) bool

check the secret based on hmac function method

func UserFromIncompleteSession

func UserFromIncompleteSession(u *core.User, ctx echo.Context) bool

check that the user token is incomplete and exists

func UserFromSession

func UserFromSession(u *core.User, ctx echo.Context) bool

check that the user is fully logged in using her cookie

func WebHookLogDetailHandler

func WebHookLogDetailHandler(ctx echo.Context) error

admin/webhooklog/detail/:id renders a given webhook event with the response and request

func WebHookLogHandler

func WebHookLogHandler(ctx echo.Context) error

/admin/webhooklog and /admin/webhooklog/:repoid renders a listing of the received webhook events

func WriteCookie

func WriteCookie(ctx echo.Context, name string, value string, expires time.Time)

set a cookie at the end users browser

Types

type Server

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

structure for globally known values inside the web-package

func NewServer

func NewServer(c *core.Config, d *gorm.DB) Server

sets up the echo server

func (*Server) Routes

func (s *Server) Routes()

the routing "table"

func (*Server) Start

func (s *Server) Start()

starts the server and prints minor debug information

Jump to

Keyboard shortcuts

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