Documentation ¶
Index ¶
- Variables
- func HandleCORS(w http.ResponseWriter, r *http.Request)
- func NewID() string
- func PathParts(p string) []string
- func ServeHTTPS(h http.Handler, acmeConfig ACMEConfig) error
- type ACMEConfig
- type Admin
- type App
- type AuthClient
- type AuthDB
- type ChecksumServer
- type Command
- type Comment
- type Counter
- type DB
- type ExecRequest
- type Field
- type File
- type FileServer
- type Folder
- type Function
- type ID
- type LoginRequeset
- type Metadata
- type MetadataServer
- type Model
- type Name
- type OrgServer
- type Organization
- type Path
- type Platform
- func (p *Platform) BuildAll() error
- func (p *Platform) BuildGoFunc(pkg, fn string) error
- func (p *Platform) Install() error
- func (p *Platform) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (p *Platform) ServeHTTPNext(w http.ResponseWriter, r *http.Request)
- func (p *Platform) Start() error
- func (p *Platform) Upgrade() error
- func (p *Platform) UserID(sessionToken string) string
- func (p *Platform) WriteFile(host, path string, file *File) error
- type Platform2
- type Request
- type Server
- type Session
- type Table
- func (t *Table) Delete(id string) error
- func (t *Table) Get(id string) (*File, error)
- func (t *Table) List(filter func(*File) bool) ([]*File, error)
- func (t *Table) Post(owners map[string]bool, data []byte) (string, error)
- func (t *Table) Put(id string, value []byte) error
- func (t *Table) Search(search string) ([]*File, error)
- func (t *Table) Type() golang.Ident
- type Type
- type User
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidPassword = errors.New("invalid password")
var ErrInvalidRegistrationCode = errors.New("invalid registration code")
var ErrInvalidSession = errors.New("invalid session")
var ErrUserNotFound = errors.New("user not found")
Functions ¶
func HandleCORS ¶
func HandleCORS(w http.ResponseWriter, r *http.Request)
func ServeHTTPS ¶
func ServeHTTPS(h http.Handler, acmeConfig ACMEConfig) error
Types ¶
type ACMEConfig ¶
func (*ACMEConfig) CertManager ¶
func (c *ACMEConfig) CertManager() autocert.Manager
func (*ACMEConfig) HTTPSServer ¶
type Admin ¶
type Admin struct { PhoneNumber string TwillioAccountSID string TwillioAuthToken string TwillioPhoneNumber string }
Admin is a web administrator.
type AuthClient ¶
type AuthClient struct {
AuthServerAddr string
}
func (*AuthClient) CreateInviteCode ¶
func (c *AuthClient) CreateInviteCode()
func (*AuthClient) Login ¶
func (c *AuthClient) Login()
func (*AuthClient) Logout ¶
func (c *AuthClient) Logout()
func (*AuthClient) Register ¶
func (c *AuthClient) Register()
func (*AuthClient) ValidateSession ¶
func (c *AuthClient) ValidateSession(s *Session) error
type AuthDB ¶
type AuthDB struct { // Users are the users of the service. Users map[string]*User `json:"users"` // PasswordSalt is used to salt passwords. PasswordSalt []byte `json:"password_salt"` // RegistrationCodes are needed to create new users. // Codes can be created by sending a POST request to /register with a valid registrar key. RegistrationCodes map[string]bool `json:"registration_codes"` // RegistrarKey is a secret key that is needed to generate registration codes. // If your service is open to new signups, you can share this string publicly. RegistrarKey string `json:"registrar_key"` // contains filtered or unexported fields }
AuthDB is a service for authentication. It is intended to be set up as a service that is used by other services and not end users. It is intended to be used on the open internet.
func (*AuthDB) Login ¶
Login returns a new session token for the given user ID and password. If it returns an error, it will be of type ErrInvalidPassword or ErrUserNotFound.
func (*AuthDB) Register ¶
Register creates a new user with the given password and returns the new user's ID. If it returns an error, it will be of type ErrInvalidRegistrationCode.
type ChecksumServer ¶
type ChecksumServer struct {
Dir string
}
ChecksumServer is a server for checksums.
func (*ChecksumServer) ServeHTTP ¶
func (s *ChecksumServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serves HTTP requests.
type ExecRequest ¶
type File ¶
type File struct { // Type is the type of the file. // It can be one of the following: // - any builtin Go type // - any type defined in the Go standard library // - any exported type defined in a public MIT licensed library on pkg.go.dev Type string `json:"type"` // Owner is the ID of the organization that owns the file. Owner string `json:"owner"` // Owners is a map of user IDs that own the file. // Deprecated: Use Owner instead. Owners map[string]bool `json:"owners"` // Name is the name of the file. // Deprecated: Use EnglishName instead. Name string `json:"name"` // EnglishName is the English-language name of the file. EnglishName english.Name `json:"english_name"` // Doc is the documentation for the file. Doc string `json:"doc"` // Comments are a list of comments on the file. Comments []Comment `json:"comments"` // Public decides whether the file is publicly available or not. // This means it can be viewed by anyone. // It can still only be edited by members of the owner organization. Public bool `json:"public"` // CreatedAt is the Unix timestamp of when the file was created. CreatedAt int64 `json:"created_at"` // UpdatedAt is the Unix timestamp of when the file was last updated. UpdatedAt int64 `json:"updated_at"` // SHA256 is the SHA256 hash of the file. SHA256 string `json:"sha256"` // Size is the size of the file in bytes. Size int64 `json:"size"` }
File is core concept in the web library. It is used throughout the package to represent files and directories. It doesn't actually contain the file's contents, but a SHA256 hash of the file's contents.
type FileServer ¶
type FileServer struct {
AuthServerAddr string
}
FileServer is a data structure that implements the http.Handler interface. It serves files and directories on the open web. Clients can GET and PUT files and directories.
func (*FileServer) ServeHTTP ¶
func (s *FileServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serves HTTP requests for files. GET /path/to/file returns the file. PUT /path/to/file creates or updates the file. GET /path/to/dir returns the directory as a special type of file.
type LoginRequeset ¶
type Metadata ¶
type Metadata struct { // Type is the type of the file. // It can be one of the following: // - any builtin Go type // - any type defined in the Go standard library // - any exported type defined in a public MIT licensed library on pkg.go.dev Type string `json:"type"` // Owner is the ID of the organization that owns the file. Owner string `json:"owner"` // Owners is a map of user IDs that own the file. // Deprecated: Use Owner instead. Owners map[string]bool `json:"owners"` // Name is the name of the file. // Deprecated: Use EnglishName instead. Name string `json:"name"` // EnglishName is the English-language name of the file. EnglishName english.Name `json:"english_name"` // Doc is the documentation for the file. Doc string `json:"doc"` // Comments are a list of comments on the file. Comments []Comment `json:"comments"` // Public decides whether the file is publicly available or not. // This means it can be viewed by anyone. // It can still only be edited by members of the owner organization. Public bool `json:"public"` // CreatedAt is the Unix timestamp of when the file was created. CreatedAt int64 `json:"created_at"` // UpdatedAt is the Unix timestamp of when the file was last updated. UpdatedAt int64 `json:"updated_at"` // SHA256 is the SHA256 hash of the file. SHA256 string `json:"sha256"` // Size is the size of the file in bytes. Size int64 `json:"size"` }
Metadata is the metadata for a file.
type MetadataServer ¶
MetadataServer is a server for global metadata.
func (MetadataServer) Owner ¶
func (s MetadataServer) Owner(path Path) string
Owner returns the owner of the given path.
func (MetadataServer) Owners ¶
func (s MetadataServer) Owners(path Path) map[string]bool
Owners returns the owners of the given path. Deprecated.
func (MetadataServer) ServeHTTP ¶
func (s MetadataServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP serves HTTP requests for metadata.
type Organization ¶
type Organization struct { // EnglishName is the English-language name of the organization. EnglishName english.Name `json:"english_name"` // Memebers is a list of UserIDs of the members of the organization. Members []string `json:"members"` }
Org is an organization. Organizations are
type Platform ¶
type Platform struct { // LetsEncryptEmail is the email address used to register with Let's Encrypt. LetsEncryptEmail string `json:"lets_encrypt_email"` // DataDir is a path to the directory where the platform stores its data. // The following subdirectories are used: // - src: source code // - logs: request logs // - certs: TLS certificates // - public: public files // - types: type metadata // - functions: function metadata // - bin: compiled binaries // - user_data: user data DataDir string `json:"data_dir"` // contains filtered or unexported fields }
Platform is the main type for the web platform. It implements the http.Handler interface. DataDir is the directory where the platform stores its data.
func (*Platform) BuildGoFunc ¶
func (*Platform) Install ¶
Install installs the platform. It copies the systemd files and starts the platform service.
func (*Platform) ServeHTTP ¶
func (p *Platform) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP is the main request handler for the platform.
func (*Platform) ServeHTTPNext ¶
func (p *Platform) ServeHTTPNext(w http.ResponseWriter, r *http.Request)
ServeHTTPNext is the next version of the ServeHTTPNext function. It is a work in progress.
type Platform2 ¶
type Request ¶
type Table ¶
func (*Table) Post ¶
Post adds a new file to the table. A random name is given to the file and returned.
type User ¶
type User struct { PasswordHash string `json:"password_hash"` SessionTokens map[string]bool `json:"session_tokens"` Emails []string `json:"emails"` Orgs map[string]bool `json:"orgs"` }
func (*User) PrimaryEmail ¶
PrimaryEmail returns the primary email address of the user. It panic if the user has no email addresses.
Source Files ¶
- accept.go
- acme_config.go
- admin.go
- app.go
- auth_client.go
- auth_db.go
- build_request.go
- checksum.go
- checksum_server.go
- command.go
- comment.go
- counter.go
- db.go
- errors.go
- exec_request.go
- field.go
- file.go
- file_server.go
- folder.go
- function.go
- handle_cors.go
- html_template.go
- id.go
- is_get.go
- is_html.go
- is_post.go
- login_request.go
- metadata.go
- metadata_server.go
- model.go
- name.go
- new_id.go
- org_server.go
- organization.go
- parse_path.go
- path.go
- path_parts.go
- platform.go
- platform2.go
- request.go
- serve_https.go
- server.go
- session.go
- table.go
- type.go
- user.go
- write_html.go