errorly

package
v0.0.0-...-a9e2aaa Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigurationPath = "errorly.yaml"

ConfigurationPath is the path to the file the configration will be located at.

View Source
const VERSION = "0.4.1+30032021"

VERSION respects semantic versioning.

Variables

View Source
var ErrMissingSecret = xerrors.New("Invalid secret '%s' provided")

ErrMissingSecret is raised when no/invalid secret is specified for cookie signing.

Functions

func APIMeHandler

func APIMeHandler(er *Errorly) http.HandlerFunc

APIMeHandler handles the /api/me request which returns the user object and a list of partial project objects.

func APIProjectContributorsHandler

func APIProjectContributorsHandler(er *Errorly) http.HandlerFunc

APIProjectContributorsHandler returns a list of partial users from all contributor IDs.

func APIProjectContributorsRemoveHandler

func APIProjectContributorsRemoveHandler(er *Errorly) http.HandlerFunc

APIProjectContributorsRemoveHandler handles removing a contributor.

func APIProjectCreateHandler

func APIProjectCreateHandler(er *Errorly) http.HandlerFunc

APIProjectCreateHandler creates a new project and returns the project made.

func APIProjectDeleteHandler

func APIProjectDeleteHandler(er *Errorly) http.HandlerFunc

APIProjectDeleteHandler handles deleting a project. Only the project creator can do this.

func APIProjectExecutorHandler

func APIProjectExecutorHandler(er *Errorly) http.HandlerFunc

APIProjectExecutorHandler handles executing jobs.

func APIProjectFetchIssueHandler

func APIProjectFetchIssueHandler(er *Errorly) http.HandlerFunc

APIProjectFetchIssueHandler returns an issue from a project.

func APIProjectHandler

func APIProjectHandler(er *Errorly) http.HandlerFunc

APIProjectHandler returns the initial project information and the first page of the project issues.

func APIProjectIntegrationCreate

func APIProjectIntegrationCreate(er *Errorly) http.HandlerFunc

APIProjectIntegrationCreate handles creating an integration.

func APIProjectIntegrationDelete

func APIProjectIntegrationDelete(er *Errorly) http.HandlerFunc

APIProjectIntegrationDelete handles deleting an integration.

func APIProjectIntegrationRegenerate

func APIProjectIntegrationRegenerate(er *Errorly) http.HandlerFunc

APIProjectIntegrationRegenerate handles regenerating an integration token.

func APIProjectIntegrationTokenHandler

func APIProjectIntegrationTokenHandler(er *Errorly) http.HandlerFunc

APIProjectIntegrationTokenHandler handles returning an integration token.

func APIProjectInviteCreateHandler

func APIProjectInviteCreateHandler(er *Errorly) http.HandlerFunc

APIProjectInviteCreateHandler handles creating an invite.

func APIProjectInviteDeleteHandler

func APIProjectInviteDeleteHandler(er *Errorly) http.HandlerFunc

APIProjectInviteDeleteHandler handles deleting an invite.

func APIProjectInviteGetHandler

func APIProjectInviteGetHandler(er *Errorly) http.HandlerFunc

APIProjectInviteGetHandler handles retrieving an invite.

func APIProjectInviteUseHandler

func APIProjectInviteUseHandler(er *Errorly) http.HandlerFunc

APIProjectInviteUseHandler handles a user joining an invite.

func APIProjectIssueCommentCreateHandler

func APIProjectIssueCommentCreateHandler(er *Errorly) http.HandlerFunc

APIProjectIssueCommentCreateHandler handles the creation of issue comments.

func APIProjectIssueCommentHandler

func APIProjectIssueCommentHandler(er *Errorly) http.HandlerFunc

APIProjectIssueCommentHandler returns a list of comments from an issue and returns paginated results.

func APIProjectIssueCreateHandler

func APIProjectIssueCreateHandler(er *Errorly) http.HandlerFunc

APIProjectIssueCreateHandler creates a new issue or increments an already made issue.

func APIProjectIssueDeleteHandler

func APIProjectIssueDeleteHandler(er *Errorly) http.HandlerFunc

APIProjectIssueDeleteHandler handles deleting an issue.

func APIProjectIssueHandler

func APIProjectIssueHandler(er *Errorly) http.HandlerFunc

APIProjectIssueHandler returns paginated results.

func APIProjectLazyHandler

func APIProjectLazyHandler(er *Errorly) http.HandlerFunc

APIProjectLazyHandler returns a list of partial users based on the passed user ids query.

func APIProjectTransferHandler

func APIProjectTransferHandler(er *Errorly) http.HandlerFunc

APIProjectTransferHandler handles transferring a project to another user.

func APIProjectUpdateHandler

func APIProjectUpdateHandler(er *Errorly) http.HandlerFunc

APIProjectUpdateHandler handles updating the project settings.

func APIProjectWebhookCreateHandler

func APIProjectWebhookCreateHandler(er *Errorly) http.HandlerFunc

APIProjectWebhookCreateHandler handles creating a webhook.

func APIProjectWebhookDeleteHandler

func APIProjectWebhookDeleteHandler(er *Errorly) http.HandlerFunc

APIProjectWebhookDeleteHandler handles deleting a webhook.

func APIProjectWebhookTestHandler

func APIProjectWebhookTestHandler(er *Errorly) http.HandlerFunc

APIProjectWebhookTestHandler handles testing a webhook.

func CreateUserToken

func CreateUserToken(u *structs.User) (string, string)

CreateUserToken creates a user token for a user.

func LoginHandler

func LoginHandler(er *Errorly) http.HandlerFunc

LoginHandler handles CSRF and AuthCode redirection.

func LogoutHandler

func LogoutHandler(er *Errorly) http.HandlerFunc

LogoutHandler handles clearing a user session.

func OAuthCallbackHandler

func OAuthCallbackHandler(er *Errorly) http.HandlerFunc

OAuthCallbackHandler handles authenticating discord OAuth and creating a user profile if necessary.

func ParseUserToken

func ParseUserToken(token string) (uid int64, random string, valid bool)

ParseUserToken returns the user id and random.

func RemoveStaleEntries

func RemoveStaleEntries(db *pg.DB) (err error)

Types

type Configuration

type Configuration struct {
	Host string `json:"host" yaml:"host"`

	// Used for giving the right jump link to webhooks.
	// Should be in format http://127.0.0.1:1234 with no slash
	URL string `json:"url" yaml:"url"`

	SessionSecret string `json:"secret" yaml:"secret"`

	Postgres *pg.Options    `json:"postgres" yaml:"postgres"`
	OAuth    *oauth2.Config `json:"oauth" yaml:"oauth"`

	Logging struct {
		ConsoleLoggingEnabled bool `json:"console_logging" yaml:"console_logging"`
		FileLoggingEnabled    bool `json:"file_logging" yaml:"file_logging"`

		EncodeAsJSON bool `json:"encode_as_json" yaml:"encode_as_json"` // Make the framework log as json

		Directory  string `json:"directory" yaml:"directory"`     // Directory to log into
		Filename   string `json:"filename" yaml:"filename"`       // Name of logfile
		MaxSize    int    `json:"max_size" yaml:"max_size"`       // Size in MB before a new file
		MaxBackups int    `json:"max_backups" yaml:"max_backups"` // Number of files to keep
		MaxAge     int    `json:"max_age" yaml:"max_age"`         // Number of days to keep a logfile
	} `json:"logging" yaml:"logging"`
}

Configuration represents the configuration for Errorly.

type DiscordUser

type DiscordUser struct {
	ID            snowflake.ID `json:"id" msgpack:"id"`
	Username      string       `json:"username" msgpack:"username"`
	Discriminator string       `json:"discriminator" msgpack:"discriminator"`
	Avatar        string       `json:"avatar" msgpack:"avatar"`
	// MFAEnabled    bool         `json:"mfa_enabled,omitempty" msgpack:"mfa_enabled,omitempty"`
	// Locale        string       `json:"locale,omitempty" msgpack:"locale,omitempty"`
	Verified bool `json:"verified,omitempty" msgpack:"verified,omitempty"`
}

DiscordUser is the structure of a /users/@me request.

type Errorly

type Errorly struct {
	Configuration *Configuration `json:"configuration"`

	Logger zerolog.Logger `json:"-"`

	Postgres      *pg.DB
	PostgressConn *pg.Conn

	Router *MethodRouter
	Store  *sessions.CookieStore
	IDGen  *idgenerator.IDGenerator
	// contains filtered or unexported fields
}

Errorly represents the global application state.

func NewErrorly

func NewErrorly(logger io.Writer, level zerolog.Level) (er *Errorly, err error)

NewErrorly creates an Errorly instance.

func (*Errorly) AuthenticateSession

func (er *Errorly) AuthenticateSession(session *sessions.Session) (auth bool, user *structs.User)

AuthenticateSession verifies the session is valid.

func (*Errorly) ConvertErrorlyToDiscordWebhook

func (er *Errorly) ConvertErrorlyToDiscordWebhook(payload structs.WebhookMessage) (bool, sandwich.WebhookMessage)

ConvertErrorlyToDiscordWebhook handles converting a default payload to a suitable discord webhook payload.

func (*Errorly) DoWebhook

func (er *Errorly) DoWebhook(webhook *structs.Webhook, payload structs.WebhookMessage) (ok bool, err error)

DoWebhook handles a webhook message.

func (*Errorly) ExecuteWebhook

func (er *Errorly) ExecuteWebhook(webhook *structs.Webhook, body io.Reader, secret string) (ok bool, err error)

ExecuteWebhook executes a webhook.

func (*Errorly) HandleProjectWebhook

func (er *Errorly) HandleProjectWebhook(project *structs.Project, payload structs.WebhookMessage) (err error)

HandleProjectWebhook handles sending a webhook.

func (*Errorly) HandleRequest

func (er *Errorly) HandleRequest(ctx *fasthttp.RequestCtx)

HandleRequest handles incoming HTTP requests.

func (*Errorly) LoadConfiguration

func (er *Errorly) LoadConfiguration(path string) (configuration *Configuration, err error)

LoadConfiguration loads the configuration for RestTunnel.

func (*Errorly) Open

func (er *Errorly) Open(removeStaleEntries bool) (err error)

Open starts the web worker.

func (*Errorly) SaveSession

func (er *Errorly) SaveSession(s *sessions.Session, r *http.Request, rw http.ResponseWriter)

SaveSession should be used as a defer when handling requests.

type MethodRouter

type MethodRouter struct {
	*mux.Router
}

MethodRouter beepboop.

func NewMethodRouter

func NewMethodRouter() *MethodRouter

NewMethodRouter creates a new method router.

func (*MethodRouter) HandleFunc

func (mr *MethodRouter) HandleFunc(path string, f func(http.ResponseWriter, *http.Request),
	methods ...string) *mux.Route

HandleFunc registers a route that handles both paths and methods.

Jump to

Keyboard shortcuts

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