utils

package
v0.0.0-...-274cf96 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const HandleOrganizationPermission = "handleorganization"
View Source
const OrganizationAdminGroup = "organizationadmin"

Variables

This section is empty.

Functions

func ApplyCacheBuster

func ApplyCacheBuster(content string, extensions []string) string

Replaces file paths in the content with paths that include a cache buster string.

func CacheReader

func CacheReader(path string) (string, error)

cacheReader processes a file path by removing characters after '--' and ensuring it has an appropriate extension.

func CompareHashAndPassword

func CompareHashAndPassword(hash, password string) error

func CreateFakeUsers

func CreateFakeUsers(a string)

func CreateSuperuser

func CreateSuperuser()

func FileCacheInit

func FileCacheInit(baseDir string, baseUrl string, apiUrl string, cache *map[string][]byte) error

func GenerateTokenHex

func GenerateTokenHex(nBytes int) (string, error)

func HashPassword

func HashPassword(password string) (string, error)

func IsValidEmail

func IsValidEmail(email string) bool

func RespondWithJSON

func RespondWithJSON(w http.ResponseWriter, payload interface{})

func Root

func Root(w http.ResponseWriter, r *http.Request)

func RunGoose

func RunGoose(cmd string)

This runs goose out of go4lage.

func SetUp

func SetUp() (*pgxpool.Pool, func())

func SetupGroupsAndPermissions

func SetupGroupsAndPermissions()

This does setup your groups and permissions, so that you do not have to enter the admin dashboard. It is purely additive. It will not delete anything. Use this to make sure that your permissions are added to the database.

Types

type App

type App struct {
	Queries *db.Queries
}

func (*App) AuthMiddleware

func (app *App) AuthMiddleware(group string, permission string) func(http.Handler) http.Handler

This makes sure that only logged in users can access the route. If you enter a group or permission only users with one of them will be able to use this route. It adds the user to the context as well.

type ErrorResponse

type ErrorResponse struct {
	Detail string `json:"detail"`
	Error  string `json:"error"`
}

type Info

type Info struct{}
var InfoContextKey Info

type InfoKey

type InfoKey struct {
	User         db.User
	Organization db.Organization
	Groups       []string
	Permissions  []string
}

type ToastResponse

type ToastResponse struct {
	Header string `json:"header"`
	Text   string `json:"text"`
}

Jump to

Keyboard shortcuts

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