Documentation ¶
Index ¶
- Variables
- func Accept(r *http.Request, format string) bool
- func AddToKnownHosts(user, server string) error
- func AppendUsingReflect(slice any, value any) any
- func AuthenticateTailscale(authkey string) error
- func BackupDir(path string, encKey string, outfile string) error
- func Bit(b byte, i int) bool
- func DecryptAndDecompressDir(src io.Reader, dst string, key string) error
- func DeleteCookie(w http.ResponseWriter, name string)
- func Download(url, target string) error
- func EncryptAndCompressDir(src string, buf io.Writer, key string) error
- func EncryptedReader(key string, r io.Reader) (*cipher.StreamReader, error)
- func EncryptedWriter(key string, w io.Writer) (*cipher.StreamWriter, error)
- func EnvVar(name string, def string) string
- func Exists(path string) bool
- func FReadJSONFile(fsys fs.FS, path string, v any) error
- func FieldValue(v any, f string) any
- func FilterTestFiles(fi fs.FileInfo) bool
- func Flatten(v any) map[string]string
- func FprintJSON(w io.Writer, v any) (int, error)
- func GetAddr() string
- func GetName(v any) string
- func GetOSID() (string, error)
- func HandleCORS(w http.ResponseWriter, r *http.Request)
- func HandlePUT(w http.ResponseWriter, r *http.Request, v any)
- func HasMethod(v any, m string) bool
- func HomeDir() string
- func InstallGo() error
- func InstallNode() error
- func InstallTailscale() error
- func IntToID(v int64) string
- func IsAlphaNumeric(ch rune) bool
- func IsArray(v any) bool
- func IsBool(v any) bool
- func IsDir(path string) bool
- func IsInt(v any) bool
- func IsMap(v any) bool
- func IsMutation(r *http.Request) bool
- func IsRootRequest(r *http.Request) bool
- func IsString(v any) bool
- func IsStruct(v any) bool
- func IsTenDigits(phone string) bool
- func JSONString(v any) string
- func JoinPath(path []string) string
- func KebabCase(s string) string
- func Main(s http.Handler)
- func NewRecursiveWatcher(dir string) (*fsnotify.Watcher, error)
- func NormalizeGoName(s string) string
- func OS() string
- func OnlyLowerCase(s string) string
- func OnlyOne[T any](m map[string]T) (id string, value T, ok bool)
- func PackageManager() string
- func ParsePath(s string) []string
- func PascalCase(s string) string
- func Pop[T any](items []T) (T, []T)
- func PopPath(path string) (first string, rest string, isRoot bool)
- func PrintJSON(v any) (int, error)
- func RandomBits(n int) []bool
- func RandomBytes(n int) []byte
- func RandomCode(digits int) string
- func RandomDigit() int
- func RandomID() string
- func RandomToken(bytes int) string
- func ReadGoPackageFromDisk(dir string) (*ast.Package, error)
- func ReadJSON[T any](r io.Reader) *T
- func ReadJSONFile[T any](path string) T
- func ReloadSystemd() error
- func RequireEnvVar(name string) string
- func RestoreDir(backupFile string, encKey string, outDir string) error
- func Run(cmd *exec.Cmd) error
- func RunSSHCommandWithKnownHostsCheck(host, user, cmd string, auth []ssh.AuthMethod) error
- func SHA256(b []byte) []byte
- func SSHClientConfig(user string) (*ssh.ClientConfig, error)
- func Serialize(v any) []byte
- func Serve(s http.Handler) error
- func ServeAll(handlers map[string]http.Handler) error
- func ServeBool(path []string, v any, w http.ResponseWriter, r *http.Request)
- func ServeError(w http.ResponseWriter, code int)
- func ServeHTTPS(s http.Handler, email, certDir string) error
- func ServeMethod(m string, v any, w http.ResponseWriter, r *http.Request)
- func ServeObject(path []string, v Object, w http.ResponseWriter, r *http.Request)
- func SetField(v any, fieldName string, fieldValue any)
- func SnakeCase(s string) string
- func StripNonAlphaNumeric(s string) string
- func StructToMap(val any) map[string]any
- func Sync(src, dst string) error
- func TitleCase(s string) string
- func UnixNanoTimestamp() string
- func UnixTimestamp() string
- func Watch(path string, fn func()) error
- func WriteFile(path string, b []byte) error
- func WriteJSON(w http.ResponseWriter, v any)
- func WriteJSONFile(path string, v any) error
- func WriteMethodNotAllowed(w http.ResponseWriter)
- func WriteNotFound(w http.ResponseWriter)
- type Account
- type Action
- type App
- type AppConfig
- type AppServer
- type Array
- type AuthMethod
- type AuthSystem
- func (a *AuthSystem) CheckLoginCode(userID, code string) bool
- func (a *AuthSystem) CreateLoginCode(userID string) string
- func (a *AuthSystem) Login(userID, code string) (token string, err error)
- func (a *AuthSystem) Logout(token string)
- func (a *AuthSystem) Register(user *User) (string, error)
- func (a *AuthSystem) SendLoginCode(phone string) (userID string, err error)
- func (a *AuthSystem) WhoAmI(token string) string
- type BlogPost
- type Bool
- type BuildConfig
- type BuildServer
- type CI
- type Cafe
- type Collection
- type Condition
- type DB
- func (db *DB) AddColumn(table, column, typ string) error
- func (db *DB) CreateTable(name string) error
- func (db *DB) Delete(name string) error
- func (db *DB) Insert(name string) error
- func (db *DB) SelectMany(name string) error
- func (db *DB) SelectOne(name string) error
- func (db *DB) Update(name string) error
- type DevServer
- type Email
- type Error
- type Expression
- type FancyRoute
- type FancyRouter
- type Field
- type File
- type FileObject
- type FileStore
- type FileSystem
- type Form
- type Function
- type GitRepo
- type GithubMirror
- type GithubRepository
- type GithubWebhook
- type GithubWebhookRequest
- type GoCodebase
- type GoPackage
- type GoWorkspace
- type HCloudStorageFileSystem
- type HTMLDocument
- type HTMLHead
- type HTMLTemplateData
- type Index
- type Int
- type JSONFile
- type Link
- type LinkTree
- type List
- type ListItem
- type LocalFileSystem
- func (fs *LocalFileSystem) Dig(path string) FileSystem
- func (fs *LocalFileSystem) IsDir(path string) bool
- func (fs *LocalFileSystem) IsFile(path string) bool
- func (fs *LocalFileSystem) MakeDir(path string) error
- func (fs *LocalFileSystem) ReadDir(path string) ([]string, error)
- func (fs *LocalFileSystem) ReadFile(path string) ([]byte, error)
- func (fs *LocalFileSystem) Remove(path string) error
- func (fs *LocalFileSystem) WriteFile(path string, b []byte) error
- type Map
- type MapList
- type Metadata
- type Movie
- type MultiHostServer
- type MultiUserApp
- func (a *MultiUserApp) AuthHandler() *MultiUserAuthHandler
- func (a *MultiUserApp) Authorized(r *http.Request) (bool, string, error)
- func (a *MultiUserApp) GetOrg(id string) (*Org, error)
- func (a *MultiUserApp) GetSession(token string) (*Session, error)
- func (a *MultiUserApp) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type MultiUserAuthHandler
- type Nil
- type Object
- type Org
- type Pair
- type Person
- type Personal
- type PhoneNumber
- type PingServer
- type ProgrammingLanguage
- type ReactComponent
- type ReactElement
- type Ref
- type RemoteFileSystem
- func (fs *RemoteFileSystem) IsDir(path string) bool
- func (fs *RemoteFileSystem) IsFile(path string) bool
- func (fs *RemoteFileSystem) MakeDir(path string) error
- func (fs *RemoteFileSystem) ReadDir(path string) ([]string, error)
- func (fs *RemoteFileSystem) ReadFile(path string) ([]byte, error)
- func (fs *RemoteFileSystem) Remove(path string) error
- func (fs *RemoteFileSystem) WriteFile(path string, b []byte) error
- type Request
- type Router
- type SHA256Server
- type Schema
- type SchemaCafe
- type Sender
- type Server
- func (a *Server) CheckLoginCode(userID, code string) bool
- func (a *Server) CreateLoginCode(userID string) string
- func (s *Server) GithubMirror() *GithubMirror
- func (s *Server) HostPolicy(ctx context.Context, host string) error
- func (s *Server) Load()
- func (s *Server) LogError(e any)
- func (a *Server) LoginForm() *Form
- func (a *Server) Logout(token string)
- func (a *Server) LogoutForm() *Form
- func (s *Server) NotifyAdmin(msg string)
- func (s *Server) RegisterForm() *Form
- func (a *Server) SendLoginCodeForm() *Form
- func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *Server) Start() error
- func (s *Server) SystemdService() *SystemdService
- func (s *Server) User(r *http.Request) *User
- func (a *Server) WhoAmI(token string) string
- type Session
- type Set
- type SheetsDB
- type SingleFileServer
- type SinglePageApp
- type SingleUserApp
- func (a *SingleUserApp) AuthFiles() FileSystem
- func (a *SingleUserApp) AuthHandler() *SingleUserAuthHandler
- func (a *SingleUserApp) Authorized(r *http.Request) (bool, error)
- func (a *SingleUserApp) GetSession(token string) (*Session, error)
- func (app *SingleUserApp) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type SingleUserAuthHandler
- type Statement
- type String
- type Struct
- type SystemdService
- type TVEpisode
- type TVSeason
- type TVShow
- type Table
- func (t *Table[T]) AddIndex(fieldID string) error
- func (t *Table[T]) AddUniqConstraint(col string) error
- func (t *Table[T]) Delete(id string)
- func (t *Table[T]) Find(id string) (T, bool)
- func (t *Table[T]) FindBy(col string, value any) map[string]T
- func (t *Table[T]) IDs() Set[string]
- func (t *Table[T]) Insert(v T) (string, error)
- func (t *Table[T]) List(page int) *List
- func (t *Table[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (t *Table[T]) Update(id string, v T) error
- type TableConstraint
- type TwilioClient
- type Type
- type User
- type Video
- type WebAPI
- type WebApp
- func (app *WebApp[T]) AuthHandler() *MultiUserAuthHandler
- func (app *WebApp[T]) DeletePath(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) GetAuthLogin(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) GetAuthSendLoginCode(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) GetFavicon(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) GetMeta(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) GetOrg(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) GetPath(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) GetRoot(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) KeywordString() string
- func (app *WebApp[T]) Metadata() *Metadata
- func (app *WebApp[T]) OrgTmpl() *template.Template
- func (app *WebApp[T]) PatchPath(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) PostAuthLogin(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) PostAuthSendLoginCode(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) PostOrg(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) PostPath(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) PostRoot(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) PutOrg(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) PutPath(w http.ResponseWriter, r *http.Request)
- func (app *WebApp[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type WebFrontend
- type WebpageMetadata
- type XML
Constants ¶
This section is empty.
Variables ¶
var StringType = &Type{ IsScalar: true, Kind: "string", }
Functions ¶
func AddToKnownHosts ¶
func AppendUsingReflect ¶
func AuthenticateTailscale ¶
func Bit ¶
Bit returns the bit value of the bit at index i of b. It panics if i is out of range (1-8).
func DecryptAndDecompressDir ¶
func DeleteCookie ¶
func DeleteCookie(w http.ResponseWriter, name string)
func EncryptAndCompressDir ¶
func EncryptedReader ¶
EncryptedReader wraps r with an OFB cipher stream.
func EncryptedWriter ¶
EncryptedWriter wraps w with an OFB cipher stream.
func FieldValue ¶
func FilterTestFiles ¶
func HandleCORS ¶
func HandleCORS(w http.ResponseWriter, r *http.Request)
func InstallNode ¶
func InstallNode() error
func InstallTailscale ¶
func InstallTailscale() error
func IsAlphaNumeric ¶
func IsMutation ¶
func IsRootRequest ¶
func IsTenDigits ¶
func JSONString ¶
func NormalizeGoName ¶
func OnlyLowerCase ¶
func PackageManager ¶
func PackageManager() string
func PascalCase ¶
func RandomBits ¶
func RandomBytes ¶
func RandomCode ¶
func RandomDigit ¶
func RandomDigit() int
func RandomID ¶
func RandomID() string
RandomID returns a 32-byte hex encoded string. The first 8 bytes are a nano-second precision UNIX time-stamp. The next 24 bytes are generated by /dev/urandom.
func RandomToken ¶
func ReadJSONFile ¶
func ReloadSystemd ¶
func ReloadSystemd() error
func RequireEnvVar ¶
func RunSSHCommandWithKnownHostsCheck ¶
func RunSSHCommandWithKnownHostsCheck(host, user, cmd string, auth []ssh.AuthMethod) error
func SSHClientConfig ¶
func SSHClientConfig(user string) (*ssh.ClientConfig, error)
func ServeError ¶
func ServeError(w http.ResponseWriter, code int)
func ServeHTTPS ¶
Use Let's Encrypt to fetch and renew certificates on any domain. serveHTTPS binds to ports 80 and 443 and serves the given handler. It uses a special handler for port 80 that can handle ACME challenges.
func ServeMethod ¶
func ServeObject ¶
func StripNonAlphaNumeric ¶
func StructToMap ¶
func UnixNanoTimestamp ¶
func UnixNanoTimestamp() string
func UnixTimestamp ¶
func UnixTimestamp() string
func WriteJSON ¶
func WriteJSON(w http.ResponseWriter, v any)
func WriteJSONFile ¶
func WriteMethodNotAllowed ¶
func WriteMethodNotAllowed(w http.ResponseWriter)
func WriteNotFound ¶
func WriteNotFound(w http.ResponseWriter)
Types ¶
type AuthMethod ¶
type AuthSystem ¶
type AuthSystem struct { // Config TwilioClient *TwilioClient LoginCodeMsgFmt string // Data Users *Table[*User] LoginCodes map[string]string // user ID => 6 digit code SessionTokens map[string]string // token => user ID }
func NewAuthSystem ¶
func NewAuthSystem() *AuthSystem
func (*AuthSystem) CheckLoginCode ¶
func (a *AuthSystem) CheckLoginCode(userID, code string) bool
CheckLoginCode returns true if the login code is valid.
func (*AuthSystem) CreateLoginCode ¶
func (a *AuthSystem) CreateLoginCode(userID string) string
Creates a new login code. Only one login code per user can be active at a time.
func (*AuthSystem) Login ¶
func (a *AuthSystem) Login(userID, code string) (token string, err error)
Login creates a user session. It returns a token or error.
func (*AuthSystem) Logout ¶
func (a *AuthSystem) Logout(token string)
func (*AuthSystem) SendLoginCode ¶
func (a *AuthSystem) SendLoginCode(phone string) (userID string, err error)
SendLoginCode sends a login code the users phone number on file via Twilio SMS.
func (*AuthSystem) WhoAmI ¶
func (a *AuthSystem) WhoAmI(token string) string
type BlogPost ¶
type BlogPost struct { Metadata *WebpageMetadata BodyHTML string }
type BuildConfig ¶
func (*BuildConfig) Build ¶
func (config *BuildConfig) Build() error
type BuildServer ¶
type BuildServer struct { Workdir string Config map[string]*BuildConfig }
func (*BuildServer) ServeHTTP ¶
func (s *BuildServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
type CI ¶
type CI struct { PeriodMinutes int SourceDir string OutFile string ServiceName string TwilioClient *TwilioClient AdminPhone string }
func (*CI) Codebase ¶
func (ci *CI) Codebase() *GoCodebase
func (*CI) Serivce ¶
func (ci *CI) Serivce() *SystemdService
type Collection ¶
func (*Collection) List ¶
func (c *Collection) List(limit, after int)
List returns a list of the first `limit` items after
type Condition ¶
type Condition struct { LHS *Expression Op string RHS *Expression }
type DB ¶
type DB struct { FS FileSystem Schema struct { Tables map[string]struct { Columns map[string]string } } }
func (*DB) CreateTable ¶
func (*DB) SelectMany ¶
type Expression ¶
type FancyRoute ¶
type FancyRoute struct { Root http.Handler Static map[string]http.Handler Catchall *FancyRoute VarName string }
func (*FancyRoute) ServeHTTP ¶
func (route *FancyRoute) ServeHTTP(w http.ResponseWriter, r *http.Request)
type FancyRouter ¶
type FancyRouter struct { // Routes. Each key should start with '/'. // To handle the root request, use the key "/". // To define a path variable, use square brackets like "/items/[itemID]". Routes map[string]http.Handler NotFound http.Handler }
FancyRouter handles HTTP requests by matching each request to a handler according to Next.js routing conventions.
func (*FancyRouter) SortedRoutes ¶
func (r *FancyRouter) SortedRoutes() []string
type FileObject ¶
func (*FileObject[T]) ServeHTTP ¶
func (fo *FileObject[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)
type FileStore ¶
type FileStore struct {
Workdir string
}
FileStore stores and serves files. To use, set up a directory with an `auth.json` file and a `content` directory.
type FileSystem ¶
type Form ¶
type GitRepo ¶
type GitRepo struct {
Dir string
}
type GithubMirror ¶
type GithubMirror struct {
Workdir string
}
func (*GithubMirror) Pull ¶
func (g *GithubMirror) Pull(repo string) error
func (*GithubMirror) ServeHTTP ¶
func (g *GithubMirror) ServeHTTP(w http.ResponseWriter, r *http.Request)
Handle webhooks from github
type GithubRepository ¶
type GithubRepository struct { ID int `json:"id"` NodeID string `json:"node_id"` FullName string `json:"full_name"` }
func (*GithubRepository) SyncLocal ¶
func (repo *GithubRepository) SyncLocal(path string) error
type GithubWebhook ¶
type GithubWebhookRequest ¶
type GithubWebhookRequest struct { Zen string `json:"zen"` HookID int `json:"hook_id"` Hook *GithubWebhook `json:"hook"` Repository *GithubRepository `json:"repository"` }
type GoCodebase ¶
type GoCodebase struct {
Dir string
}
func (GoCodebase) Build ¶
func (c GoCodebase) Build(outFile string) error
func (*GoCodebase) GitRepo ¶
func (c *GoCodebase) GitRepo() *GitRepo
func (*GoCodebase) UpdateDeps ¶
func (c *GoCodebase) UpdateDeps() (bool, error)
type GoWorkspace ¶
type GoWorkspace struct {
Dir string
}
func (*GoWorkspace) Clone ¶
func (w *GoWorkspace) Clone(pkg string) error
func (*GoWorkspace) Install ¶
func (w *GoWorkspace) Install(pkg string) error
func (*GoWorkspace) Pull ¶
func (w *GoWorkspace) Pull(pkg string) error
func (*GoWorkspace) ServeGithubWebhook ¶
func (ws *GoWorkspace) ServeGithubWebhook(w http.ResponseWriter, r *http.Request)
type HCloudStorageFileSystem ¶
type HCloudStorageFileSystem struct { HetznerStorageBoxAddr string HetznerStorageBoxUsername string HetznerStorageBoxPassword string }
func (*HCloudStorageFileSystem) NewSFTPClient ¶
func (fs *HCloudStorageFileSystem) NewSFTPClient() (*sftp.Client, error)
func (*HCloudStorageFileSystem) NewSSHClient ¶
func (fs *HCloudStorageFileSystem) NewSSHClient() (*ssh.Client, error)
type HTMLDocument ¶
type HTMLTemplateData ¶
type LocalFileSystem ¶
type LocalFileSystem struct {
Root string
}
func (*LocalFileSystem) Dig ¶
func (fs *LocalFileSystem) Dig(path string) FileSystem
func (*LocalFileSystem) IsDir ¶
func (fs *LocalFileSystem) IsDir(path string) bool
func (*LocalFileSystem) IsFile ¶
func (fs *LocalFileSystem) IsFile(path string) bool
func (*LocalFileSystem) MakeDir ¶
func (fs *LocalFileSystem) MakeDir(path string) error
func (*LocalFileSystem) Remove ¶
func (fs *LocalFileSystem) Remove(path string) error
type MultiHostServer ¶
type MultiHostServer struct { Hosts map[string]http.Handler TwilioClient *TwilioClient AdminPhone string }
func (*MultiHostServer) HostPolicy ¶
func (s *MultiHostServer) HostPolicy(ctx context.Context, host string) error
func (*MultiHostServer) ServeHTTP ¶
func (s *MultiHostServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*MultiHostServer) Start ¶
func (s *MultiHostServer) Start(email, certDir string) error
type MultiUserApp ¶
type MultiUserApp struct { Twilio *TwilioClient AuthFiles FileSystem App http.Handler }
func (*MultiUserApp) AuthHandler ¶
func (a *MultiUserApp) AuthHandler() *MultiUserAuthHandler
func (*MultiUserApp) Authorized ¶
func (*MultiUserApp) GetSession ¶
func (a *MultiUserApp) GetSession(token string) (*Session, error)
func (*MultiUserApp) ServeHTTP ¶
func (a *MultiUserApp) ServeHTTP(w http.ResponseWriter, r *http.Request)
type MultiUserAuthHandler ¶
type MultiUserAuthHandler struct { AuthFiles FileSystem Twilio *TwilioClient }
func (*MultiUserAuthHandler) Login ¶
func (a *MultiUserAuthHandler) Login(phone, code string) (*Session, error)
func (*MultiUserAuthHandler) SendLoginCode ¶
func (a *MultiUserAuthHandler) SendLoginCode(phone string) error
func (*MultiUserAuthHandler) ServeHTTP ¶
func (a *MultiUserAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Object ¶
type PhoneNumber ¶
type PhoneNumber string
func (PhoneNumber) Validate ¶
func (phone PhoneNumber) Validate() error
type PingServer ¶
type PingServer struct {
Msg string
}
func (*PingServer) ServeHTTP ¶
func (s *PingServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
type ProgrammingLanguage ¶
type ReactComponent ¶
type ReactElement ¶
type ReactElement struct { Type string Props []struct { Key string Value any } Children []ReactElement }
func (*ReactElement) WriteNextJSPage ¶
func (el *ReactElement) WriteNextJSPage(w io.Writer) error
type RemoteFileSystem ¶
type RemoteFileSystem struct {
Root string
}
func (*RemoteFileSystem) IsDir ¶
func (fs *RemoteFileSystem) IsDir(path string) bool
func (*RemoteFileSystem) IsFile ¶
func (fs *RemoteFileSystem) IsFile(path string) bool
func (*RemoteFileSystem) MakeDir ¶
func (fs *RemoteFileSystem) MakeDir(path string) error
func (*RemoteFileSystem) ReadDir ¶
func (fs *RemoteFileSystem) ReadDir(path string) ([]string, error)
func (*RemoteFileSystem) ReadFile ¶
func (fs *RemoteFileSystem) ReadFile(path string) ([]byte, error)
func (*RemoteFileSystem) Remove ¶
func (fs *RemoteFileSystem) Remove(path string) error
type Request ¶
func NewRequest ¶
type Router ¶
type Router struct { Root func(w http.ResponseWriter, r *http.Request) Next func(first string, w http.ResponseWriter, r *http.Request) }
type SHA256Server ¶
func (*SHA256Server) ServeHTTP ¶
func (s *SHA256Server) ServeHTTP(w http.ResponseWriter, r *http.Request)
type SchemaCafe ¶
func (*SchemaCafe) ServeHTTP ¶
func (sc *SchemaCafe) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Server ¶
type Server struct { DataFile string ErrorsDir string TwilioClient *TwilioClient AdminPhone string AdminEmail string CertDir string Users *Table[*User] LoginCodes map[string]string // user ID => 6 digit code SessionTokens map[string]string // token => user ID LoginCodeMsgFmt string GithubSourceDir string AllowRegistration bool }
Server hosts multiple apps. App data is read from "{datadir}/{host}/data.json". Config is "{datadir}/{host}/config.json" defined by AppConfig.
func (*Server) CheckLoginCode ¶
CheckLoginCode returns true if the login code is valid.
func (*Server) CreateLoginCode ¶
Creates a new login code. Only one login code per user can be active at a time.
func (*Server) GithubMirror ¶
func (s *Server) GithubMirror() *GithubMirror
func (*Server) LogoutForm ¶
func (*Server) NotifyAdmin ¶
func (*Server) RegisterForm ¶
func (*Server) SendLoginCodeForm ¶
func (*Server) SystemdService ¶
func (s *Server) SystemdService() *SystemdService
type SingleFileServer ¶
type SingleFileServer[T http.Handler] struct { Path string V T // contains filtered or unexported fields }
func NewSingleFileServer ¶
func NewSingleFileServer[T http.Handler](path string) *SingleFileServer[T]
func (*SingleFileServer[T]) ServeHTTP ¶
func (s *SingleFileServer[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)
type SinglePageApp ¶
type SinglePageApp struct {
// contains filtered or unexported fields
}
func (*SinglePageApp) ServeHTTP ¶
func (spa *SinglePageApp) ServeHTTP(w http.ResponseWriter, r *http.Request)
type SingleUserApp ¶
type SingleUserApp struct { Twilio *TwilioClient UserPhone string Files FileSystem Handler http.Handler }
func (*SingleUserApp) AuthFiles ¶
func (a *SingleUserApp) AuthFiles() FileSystem
func (*SingleUserApp) AuthHandler ¶
func (a *SingleUserApp) AuthHandler() *SingleUserAuthHandler
func (*SingleUserApp) Authorized ¶
func (a *SingleUserApp) Authorized(r *http.Request) (bool, error)
func (*SingleUserApp) GetSession ¶
func (a *SingleUserApp) GetSession(token string) (*Session, error)
func (*SingleUserApp) ServeHTTP ¶
func (app *SingleUserApp) ServeHTTP(w http.ResponseWriter, r *http.Request)
type SingleUserAuthHandler ¶
type SingleUserAuthHandler struct { UserPhone string AuthFiles FileSystem Twilio *TwilioClient }
func (*SingleUserAuthHandler) Login ¶
func (a *SingleUserAuthHandler) Login(phone, code string) (*Session, error)
func (*SingleUserAuthHandler) SendLoginCode ¶
func (a *SingleUserAuthHandler) SendLoginCode(phone string) error
func (*SingleUserAuthHandler) ServeHTTP ¶
func (a *SingleUserAuthHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Statement ¶
type Statement struct { IsReturn bool Return *Expression IsAssign bool Name string Value *Expression IsIf bool Condition *Condition Body []*Statement }
Statement represents a line of code in a function or method body. There are 4 types of statements: returns, assignments, ifs and loops. Ifs and loops have substatements.
type SystemdService ¶
type SystemdService struct { Name string Desc string After string Type string Env []Pair[string, string] ExecStart string AutoRestart string WantedBy string }
func (*SystemdService) Restart ¶
func (s *SystemdService) Restart() error
func (*SystemdService) WriteConfig ¶
func (s *SystemdService) WriteConfig(w io.Writer) error
func (*SystemdService) WriteConfigToFile ¶
func (s *SystemdService) WriteConfigToFile() error
type Table ¶
type Table[T any] struct { Path string Rows map[string]T Indexes map[string]Index Constraints []TableConstraint RowLimit int }
func (*Table[T]) AddUniqConstraint ¶
type TableConstraint ¶
type TwilioClient ¶
func (*TwilioClient) SendSMS ¶
func (c *TwilioClient) SendSMS(to, message string) error
type Type ¶
type User ¶
type User struct { // Public ID ID string // Contact Phone string Email string // Personal FirstName string LastName string // Data Schemas *Table[*Schema] }
func (*User) SchemaCafe ¶
func (u *User) SchemaCafe(w http.ResponseWriter, r *http.Request)
type WebAPI ¶
type WebAPI struct { Types map[string]Type RootType string Data FileSystem }
The WebAPI type represents an WebAPI backed by any JSON-serializable Go object.
func (*WebAPI) ServeHTTP ¶
func (api *WebAPI) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serves a generic REST API.
func (*WebAPI) ServeNotFound ¶
func (api *WebAPI) ServeNotFound(w http.ResponseWriter, r *http.Request)
type WebApp ¶
type WebApp[T any] struct { Name string Description string Author string Keywords []string Favicon []byte Icon []byte Types map[string]Type CoreResourceType string TwilioClient *TwilioClient Files FileSystem }
func (*WebApp[T]) AuthHandler ¶
func (app *WebApp[T]) AuthHandler() *MultiUserAuthHandler
func (*WebApp[T]) DeletePath ¶
func (app *WebApp[T]) DeletePath(w http.ResponseWriter, r *http.Request)
func (*WebApp[T]) GetAuthLogin ¶
func (app *WebApp[T]) GetAuthLogin(w http.ResponseWriter, r *http.Request)
func (*WebApp[T]) GetAuthSendLoginCode ¶
func (app *WebApp[T]) GetAuthSendLoginCode(w http.ResponseWriter, r *http.Request)
func (*WebApp[T]) GetFavicon ¶
func (app *WebApp[T]) GetFavicon(w http.ResponseWriter, r *http.Request)
func (*WebApp[T]) KeywordString ¶
func (*WebApp[T]) PatchPath ¶
func (app *WebApp[T]) PatchPath(w http.ResponseWriter, r *http.Request)
func (*WebApp[T]) PostAuthLogin ¶
func (app *WebApp[T]) PostAuthLogin(w http.ResponseWriter, r *http.Request)
func (*WebApp[T]) PostAuthSendLoginCode ¶
func (app *WebApp[T]) PostAuthSendLoginCode(w http.ResponseWriter, r *http.Request)
type WebFrontend ¶
type WebFrontend struct { Favicon []byte RootTitle string MetaDesc string MetaAuthor string MetaKeywords []string }
func (*WebFrontend) HTMLData ¶
func (fe *WebFrontend) HTMLData() *HTMLTemplateData
func (*WebFrontend) ServeHTTP ¶
func (fe *WebFrontend) ServeHTTP(w http.ResponseWriter, r *http.Request)
type WebpageMetadata ¶
Source Files ¶
- accept.go
- account.go
- action.go
- add_to_known_hosts.go
- app.go
- app_config.go
- app_server.go
- append_using_reflect.go
- array.go
- auth_method.go
- auth_system.go
- authenticate_tailscale.go
- backup_dir.go
- bit.go
- bool.go
- build_config.go
- build_server.go
- cafe.go
- ci.go
- collection.go
- condition.go
- db.go
- decrypt_and_decompress_dir.go
- delete_cookie.go
- dev_server.go
- download.go
- email.go
- encrypt_and_compress_dir.go
- env_var.go
- error.go
- exists.go
- expression.go
- field.go
- field_value.go
- file.go
- file_object.go
- file_store.go
- file_system.go
- filter_test_files.go
- flatten.go
- form.go
- fprint_json.go
- function.go
- get_addr.go
- get_name.go
- get_osid.go
- git_repo.go
- github_mirror.go
- github_repository.go
- github_webhook.go
- github_webhook_request.go
- go_codebase.go
- go_package.go
- go_workspace.go
- handle_cors.go
- handle_put.go
- has_method.go
- hcloud_file_system.go
- home_dir.go
- html_document.go
- html_head.go
- html_template.go
- html_template_data.go
- index.go
- install_go.go
- install_node.go
- install_tailscale.go
- int.go
- int_to_id.go
- is_alpha_numeric.go
- is_array.go
- is_bool.go
- is_dir.go
- is_int.go
- is_map.go
- is_mutation.go
- is_root_request.go
- is_string.go
- is_struct.go
- is_ten_digits.go
- join_path.go
- json_file.go
- json_string.go
- kebab_case.go
- link.go
- link_tree.go
- list.go
- list_item.go
- local_file_system.go
- main.go
- map.go
- map_list.go
- metadata.go
- movie.go
- multi_host_server.go
- multi_user_app.go
- multi_user_auth_handler.go
- new_object.go
- nil.go
- normalize_go_name.go
- object.go
- only_lower_case.go
- only_one.go
- org.go
- os.go
- package_manager.go
- pair.go
- parse_path.go
- pascal_case.go
- person.go
- personal.go
- phone_number.go
- ping_server.go
- pop.go
- pop_path.go
- post.go
- print_json.go
- programming_language.go
- random_bits.go
- random_bytes.go
- random_code.go
- random_digit.go
- random_id.go
- random_token.go
- react_component.go
- react_element.go
- read_go_package_from_disk.go
- read_json.go
- read_json_file.go
- ref.go
- reload_systemd.go
- remote_file_system.go
- request.go
- require_env_var.go
- restore_dir.go
- route.go
- router.go
- run.go
- run_ssh_with_known_hosts_check.go
- schema.go
- schema_cafe.go
- sender.go
- serialize.go
- serve.go
- serve_all.go
- serve_bool.go
- serve_error.go
- serve_https.go
- serve_method.go
- serve_object.go
- server.go
- session.go
- set.go
- set_field.go
- sha256.go
- sha256_server.go
- sheets_db.go
- single_file_server.go
- single_page_app.go
- single_user_app.go
- single_user_auth_handler.go
- snake_case.go
- ssh_client_config.go
- statement.go
- string.go
- string_type.go
- strip_non_alpha_numeric.go
- struct.go
- struct_to_map.go
- sync.go
- systemd_service.go
- table.go
- table_constraint.go
- title_case.go
- tv_episode.go
- tv_season.go
- tv_show.go
- twilio_client.go
- type.go
- unix_nano_timestamp.go
- unix_timestamp.go
- user.go
- valid_rel_path.go
- video.go
- watch.go
- web_api.go
- web_app.go
- web_frontend.go
- webpage_metadata.go
- write_encrypted.go
- write_file.go
- write_json.go
- write_json_file.go
- write_method_not_allowed.go
- write_not_found.go
- xml.go
- xml_string.go