server

package
v0.1.33 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserCtxKey ctxKey = "user"
)

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(botToken string, allowedUserID int64) func(http.Handler) http.Handler

Types

type FoodGroup added in v0.1.17

type FoodGroup struct {
	Name     string          `json:"name"` // "Breakfast", "Lunch", "Dinner", "Snack"
	Time     string          `json:"time"` // Approximate time (e.g. "08:30")
	Logs     []store.FoodLog `json:"logs"`
	Calories int             `json:"calories"` // Total for group
	Carbs    int             `json:"carbs"`
	Protein  int             `json:"protein"`
	Fat      int             `json:"fat"`
}

type OIDCConfig

type OIDCConfig struct {
	Provider       string
	ClientID       string
	ClientSecret   string
	RedirectURL    string
	AdminEmail     string
	AllowedSubject string
	IssuerURL      string
	AuthURL        string
	TokenURL       string
	UserInfoURL    string
	ButtonLabel    string
	ButtonColor    string
	ButtonText     string
	Scopes         []string
}

OIDC Configuration

type Server

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

func New

func New(s *store.Store, b *bot.Bot, botToken, sessionSecret string, allowedUserID int64, oidc OIDCConfig, botUsername string, vapidConfig VAPIDConfig) *Server

func (*Server) GetWebPushService

func (s *Server) GetWebPushService() *webpush.Service

func (*Server) Routes

func (s *Server) Routes() http.Handler

type TelegramLoginData

type TelegramLoginData struct {
	ID        int64  `json:"id"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name,omitempty"`
	Username  string `json:"username,omitempty"`
	PhotoURL  string `json:"photo_url,omitempty"`
	AuthDate  int64  `json:"auth_date"`
	Hash      string `json:"hash"`
}

TelegramLoginData represents data from Telegram Login Widget callback

type TelegramUser

type TelegramUser struct {
	ID        int64  `json:"id"`
	FirstName string `json:"first_name"`
	LastName  string `json:"last_name"`
	Username  string `json:"username"`
}

func ValidateTelegramLoginWidget

func ValidateTelegramLoginWidget(token string, data TelegramLoginData) (bool, *TelegramUser, error)

ValidateTelegramLoginWidget validates data from Telegram Login Widget Uses SHA256(bot_token) as secret key (different from WebApp validation)

func ValidateWebAppData

func ValidateWebAppData(token, initData string) (bool, *TelegramUser, error)

type VAPIDConfig

type VAPIDConfig struct {
	PublicKey  string
	PrivateKey string
	Subject    string
	AdminEmail string
	Domain     string
}

Jump to

Keyboard shortcuts

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