services

package
v0.0.0-...-d625e3b Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CookieNameFlash = "hypercommit_flash"
)
View Source
const (
	CookieNameUserID = "hypercommit_user_id"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthService

type AuthService interface {
	HashPassword(password string) (string, error)
	CheckPassword(password, hash string) bool
	SetUserCookie(w http.ResponseWriter, r *http.Request, userID int64)
	GetUserFromCookie(r *http.Request) (*models.User, error)
	ClearUserCookie(w http.ResponseWriter)
}

func NewAuthService

func NewAuthService(users repositories.UsersRepository, signingSecret string) AuthService

type FlashMessage

type FlashMessage struct {
	Type FlashType
}

type FlashService

type FlashService interface {
	Set(w http.ResponseWriter, r *http.Request, flashType FlashType)
	Get(r *http.Request) *FlashMessage
	Clear(w http.ResponseWriter)
}

func NewFlashService

func NewFlashService() FlashService

type FlashType

type FlashType string
const (
	FlashCelebration FlashType = "celebration"
	FlashSuccess     FlashType = "success"
	FlashError       FlashType = "error"
	FlashInfo        FlashType = "info"
)

type GitHubOAuthService

type GitHubOAuthService interface {
	GetAuthURL(state string) string
	ExchangeCode(code string) (*oauth2.Token, error)
	GetUserInfo(token *oauth2.Token) (*GitHubUser, error)
}

func NewGitHubOAuthService

func NewGitHubOAuthService(clientID, clientSecret, callbackURL string) GitHubOAuthService

type GitHubUser

type GitHubUser struct {
	ID        int64  `json:"id"`
	Login     string `json:"login"`
	Email     string `json:"email"`
	Name      string `json:"name"`
	AvatarURL string `json:"avatar_url"`
}

type GitService

type GitService interface {
	ListBranches(repoPath string) ([]string, error)
	GetDefaultBranch(repoPath string) (string, error)
	ListTree(repoPath, ref, path string) ([]TreeEntry, error)
	GetFileContent(repoPath, ref, path string) ([]byte, error)
	IsFile(repoPath, ref, path string) (bool, error)
}

func NewGitService

func NewGitService(reposBasePath string) GitService

type TreeEntry

type TreeEntry struct {
	Type string // "tree" (folder) or "blob" (file)
	Name string
	Path string
	Mode string
}

Jump to

Keyboard shortcuts

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