Documentation ¶
Index ¶
- Variables
- func HandleCORS(w http.ResponseWriter, r *http.Request)
- func IsHTML(r *http.Request) bool
- func LogRequest(r *http.Request, dir string) error
- func NewID() string
- func PathParts(p string) []string
- func ServeAny(v any, w http.ResponseWriter, r *http.Request)
- func ServeBadRequest(w http.ResponseWriter, r *http.Request)
- func ServeHTTPS(h http.Handler, acmeConfig ACMEConfig) error
- func ServeInternalServerError(w http.ResponseWriter, r *http.Request)
- func ServeMethodNotAllowed(w http.ResponseWriter, r *http.Request)
- func ServeNotFound(w http.ResponseWriter, r *http.Request)
- func ServeUnauthorized(w http.ResponseWriter, r *http.Request)
- type ACMEConfig
- type AddRequest
- type Admin
- type AppConfig
- type AuthClient
- type AuthDB
- func (s *AuthDB) GetUserFromRequest(r *http.Request) string
- func (s *AuthDB) Invite() string
- func (s *AuthDB) Login(userID, password string) (string, error)
- func (s *AuthDB) Register(registrationCode, password string) (string, error)
- func (s *AuthDB) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *AuthDB) User(id string) (*User, bool)
- type ChecksumServer
- type Collection
- type Command
- type Comment
- type Counter
- type CreateResponse
- type DevServer
- type Error
- type Event
- type ExecRequest
- type Field
- type File
- type FileServer
- type Folder
- type Function
- type HomePage
- type LoginRequeset
- type Metadata
- type MetadataServer
- type Model
- type Org
- type Path
- func (p Path) Append(name string) Path
- func (p Path) First() string
- func (p Path) Last() string
- func (p Path) Length() int
- func (p Path) Parts() []string
- func (p Path) Pop() Path
- func (p Path) Rest() Path
- func (p Path) Root() bool
- func (p Path) Second() string
- func (p Path) SecondLast() string
- func (p Path) String() string
- type Platform
- type RemoveRequest
- type Request
- type RequestLog
- type Resource
- type SaaS
- type Schema
- func (s *Schema) AddField(name english.Name, t Type) error
- func (s *Schema) ChangeFieldName(oldName, newName english.Name) error
- func (s *Schema) ChangeFieldType(fieldName english.Name, newType Type) error
- func (s *Schema) MoveField(fromIndex, toIndex int) error
- func (s *Schema) RemoveField(name english.Name) error
- func (s *Schema) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type SearchResults
- type Session
- type Type
- type User
- type View
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidPassword = NewError("invalid password")
var ErrInvalidRegistrationCode = NewError("invalid registration code")
var ErrInvalidSession = NewError("invalid session")
var ErrMethodNotSupported = NewError("method not supported")
var ErrUserNotFound = NewError("user not found")
var NoError = NewError("")
Functions ¶
func HandleCORS ¶
func HandleCORS(w http.ResponseWriter, r *http.Request)
func ServeBadRequest ¶
func ServeBadRequest(w http.ResponseWriter, r *http.Request)
func ServeHTTPS ¶
func ServeHTTPS(h http.Handler, acmeConfig ACMEConfig) error
func ServeInternalServerError ¶
func ServeInternalServerError(w http.ResponseWriter, r *http.Request)
func ServeMethodNotAllowed ¶
func ServeMethodNotAllowed(w http.ResponseWriter, r *http.Request)
func ServeNotFound ¶
func ServeNotFound(w http.ResponseWriter, r *http.Request)
func ServeUnauthorized ¶
func ServeUnauthorized(w http.ResponseWriter, r *http.Request)
Types ¶
type ACMEConfig ¶
func (*ACMEConfig) CertManager ¶
func (c *ACMEConfig) CertManager() autocert.Manager
func (*ACMEConfig) HTTPSServer ¶
type AddRequest ¶
type AddRequest struct {
ID string `json:"id"`
}
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"` // 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"` // AdminID is the UserID of the admin. AdminID string `json:"admin_id"` // 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) GetUserFromRequest ¶
GetUserFromRequest returns the user associated with the given request. If the user is not found, it returns nil.
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 Collection ¶
func (Collection[T]) Delete ¶
func (c Collection[T]) Delete(id string)
func (Collection[T]) Get ¶
func (c Collection[T]) Get(id string) (T, bool)
func (Collection[T]) Post ¶
func (c Collection[T]) Post(v T) string
func (Collection[T]) Put ¶
func (c Collection[T]) Put(id string, v T)
func (Collection[T]) ServeHTTP ¶
func (c Collection[T]) ServeHTTP(w http.ResponseWriter, r *http.Request)
type CreateResponse ¶
type ExecRequest ¶
type File ¶
type File struct { // Type is the type of the file. Type Type `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 Platform ¶
type RemoveRequest ¶
type RemoveRequest struct {
ID string `json:"id"`
}
type Request ¶
type RequestLog ¶
type Schema ¶
type Schema struct {
Fields []Field
}
func (*Schema) ChangeFieldName ¶
func (*Schema) ChangeFieldType ¶
func (*Schema) RemoveField ¶
type SearchResults ¶
type SearchResults struct{}
type Type ¶
type Type struct { // IsRef is true if the value is reference. IsRef bool `json:"is_ref"` // IsList is true if the value is a list. IsList bool `json:"is_list"` // BaseType 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 // If the ID is not builtin, it must be a valid Go import path followed by a dot and the type name. // For example, "github.com/library-development/go-web.File" is a valid ID. BaseType string `json:"base_type"` }
Type is the type of the file.
Source Files ¶
- accept.go
- acme_config.go
- add_request.go
- admin.go
- app_config.go
- auth_client.go
- auth_db.go
- build_request.go
- checksum.go
- checksum_server.go
- collection.go
- collection_html.go
- collection_tmpl.go
- command.go
- comment.go
- counter.go
- create_response.go
- db.go
- dev_server.go
- errors.go
- event.go
- exec_request.go
- field.go
- file.go
- file_server.go
- folder.go
- function.go
- handle_cors.go
- home_page.go
- html_template.go
- is_get.go
- is_html.go
- is_post.go
- log_request.go
- login_request.go
- metadata.go
- metadata_server.go
- model.go
- new_auth_db.go
- new_id.go
- new_schema.go
- new_user.go
- org.go
- parse_path.go
- parse_type.go
- password_hash.go
- password_hash_matches.go
- path.go
- path_parts.go
- platform.go
- remove_request.go
- request.go
- request_log.go
- resource.go
- saas.go
- schema.go
- search_results.go
- serve_any.go
- serve_bad_request.go
- serve_https.go
- serve_internal_server_error.go
- serve_method_not_allowed.go
- serve_not_found.go
- serve_unauthorized.go
- session.go
- table.go
- type.go
- ui_html.go
- uijs.go
- user.go
- view.go
- write_html.go