api

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logrus

func Logrus(logger *logrus.Logger) gin.HandlerFunc

func NewMiddelware

func NewMiddelware(authUrl string, db *sql.DB) *middleware

Types

type Application

type Application struct {
	Config     *Config
	Models     data.Models
	Middleware Middleware
	Migrations migrations.Migrations
	GIT        git.Repo
}

func NewApplication

func NewApplication(db *sql.DB, cfg *Config) (*Application, error)

func (*Application) Routes

func (app *Application) Routes() *gin.Engine

type Config

type Config struct {
	Port        int
	Env         string
	Version     string
	GitURL      string
	GitUserName string
	GitToken    string
	Auth        string

	DB struct {
		ConnStr      string
		MaxOpenConns int
		MaxIdleConns int
		MaxIdelTime  int
	}
}

type Middleware

type Middleware interface {
	// Authenticate determines if a user is allowed visibility on an object
	Authenticate(c *gin.Context)
	// Authorize determines if current subject has been authorized to read an object
	Authorize(code string) gin.HandlerFunc
	// HasPermission
	HasPermission(code string, permission []string) bool
}

Middleware is the interface used to control permissioning for the app

type Team

type Team struct {
	ID           int64          `json:"id"`
	Name         string         `json:"name"`
	CreatedAt    time.Time      `json:"created_at"`
	Version      int            `json:"version"`
	NumMembers   int            `json:"num_members"`
	Meta         meta           `json:"meta"`
	UserAccounts []*UserAccount `json:"user_accounts"`
}

Team represents the domain for our team entity

type UserAccount

type UserAccount struct {
	ID          int64     `json:"id"`
	Name        string    `json:"name"`
	Email       string    `json:"email"`
	Activated   bool      `json:"activated"`
	CreatedAt   time.Time `json:"created_at"`
	Version     int       `json:"-"`
	Team        *Team     `json:"team"`
	Role        string    `json:"role"`
	Permissions []string  `json:"permissions"`
}

Jump to

Keyboard shortcuts

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