Documentation ¶
Index ¶
- Constants
- Variables
- func FormatBuildVersion(version string, commit string, buildTime time.Time) string
- func GetWebhookSecret(r *http.Request) string
- func SetClaims(r *http.Request, claims Claims) *http.Request
- type Claims
- type Config
- type DeleteResponse
- type DocumentResponse
- type ErrorResponse
- type LogConfig
- type MetricsConfig
- type OtelConfig
- type Permissions
- type PreviewConfig
- type RateLimitConfig
- type RequestFile
- type ResponseFile
- type Server
- func (s *Server) Close()
- func (s *Server) DeleteDocument(w http.ResponseWriter, r *http.Request)
- func (s *Server) DeleteDocumentWebhook(w http.ResponseWriter, r *http.Request)
- func (s *Server) DocumentVersions(w http.ResponseWriter, r *http.Request)
- func (s *Server) ExecuteWebhooks(ctx context.Context, event string, document WebhookDocument)
- func (s *Server) GetDocument(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetDocumentFile(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetDocumentPreview(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetDocumentWebhook(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetPrettyDocument(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetRawDocument(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetRawDocumentFile(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetVersion(w http.ResponseWriter, _ *http.Request)
- func (s *Server) JWTMiddleware(next http.Handler) http.Handler
- func (s *Server) NewToken(documentID string, permissions Permissions) (string, error)
- func (s *Server) PatchDocument(w http.ResponseWriter, r *http.Request)
- func (s *Server) PatchDocumentWebhook(w http.ResponseWriter, r *http.Request)
- func (s *Server) PostDocument(w http.ResponseWriter, r *http.Request)
- func (s *Server) PostDocumentShare(w http.ResponseWriter, r *http.Request)
- func (s *Server) PostDocumentWebhook(w http.ResponseWriter, r *http.Request)
- func (s *Server) RateLimit(next http.Handler) http.Handler
- func (s *Server) Routes() http.Handler
- func (s *Server) Start()
- func (s *Server) ThemeCSS(w http.ResponseWriter, r *http.Request)
- type ShareRequest
- type ShareResponse
- type TraceConfig
- type WebhookConfig
- type WebhookCreateRequest
- type WebhookDocument
- type WebhookDocumentFile
- type WebhookEventRequest
- type WebhookResponse
- type WebhookUpdateRequest
Constants ¶
View Source
const ( WebhookEventUpdate string = "update" WebhookEventDelete string = "delete" )
Variables ¶
View Source
var ( ErrInvalidMultipartPartName = errors.New("invalid multipart part name") ErrInvalidDocumentFileName = errors.New("invalid document file name") ErrInvalidDocumentFileContent = errors.New("invalid document file content") ErrDuplicateDocumentFileNames = errors.New("duplicate document file names") )
View Source
var ( ErrNoPermissions = errors.New("no permissions provided") ErrUnknownPermission = func(p string) error { return fmt.Errorf("unknown permission: %s", p) } ErrPermissionDenied = func(p string) error { return fmt.Errorf("permission denied: %s", p) } )
View Source
var ( ErrDocumentNotFound = errors.New("document not found") ErrDocumentFileNotFound = errors.New("document file not found") ErrInvalidDocumentVersion = errors.New("document version is invalid") ErrPreviewsDisabled = errors.New("document previews disabled") ErrRateLimit = errors.New("rate limit exceeded") ErrContentTooLarge = func(maxLength int) error { return fmt.Errorf("content too large, must be less than %d chars", maxLength) } )
View Source
var ( ErrWebhookNotFound = errors.New("webhook not found") ErrMissingWebhookSecret = errors.New("missing webhook secret") ErrMissingWebhookURL = errors.New("missing webhook url") ErrMissingWebhookEvents = errors.New("missing webhook events") ErrMissingURLOrSecretOrEvents = errors.New("missing url, secret or events") )
View Source
var AllPermissions = PermissionWrite | PermissionDelete | PermissionShare | PermissionWebhook
View Source
var AllStringPermissions = []string{"write", "delete", "share", "webhook"}
View Source
var VersionTimeFormat = "2006-01-02 15:04:05"
Functions ¶
func FormatBuildVersion ¶
func GetWebhookSecret ¶
Types ¶
type Claims ¶
type Claims struct { jwt.Claims Permissions Permissions `json:"pms"` }
func EmptyClaims ¶
type Config ¶
type Config struct { Log LogConfig `cfg:"log"` Debug bool `cfg:"debug"` DevMode bool `cfg:"dev_mode"` ListenAddr string `cfg:"listen_addr"` HTTPTimeout time.Duration `cfg:"http_timeout"` Database database.Config `cfg:"database"` MaxDocumentSize int `cfg:"max_document_size"` MaxHighlightSize int `cfg:"max_highlight_size"` RateLimit *RateLimitConfig `cfg:"rate_limit"` JWTSecret string `cfg:"jwt_secret"` Preview *PreviewConfig `cfg:"preview"` Otel *OtelConfig `cfg:"otel"` Webhook *WebhookConfig `cfg:"webhook"` CustomStyles string `cfg:"custom_styles"` DefaultStyle string `cfg:"default_style"` }
type DeleteResponse ¶
type DeleteResponse struct {
Versions int `json:"versions"`
}
type DocumentResponse ¶
type ErrorResponse ¶
type LogConfig ¶
type MetricsConfig ¶
type MetricsConfig struct {
ListenAddr string `cfg:"listen_addr"`
}
func (MetricsConfig) String ¶
func (c MetricsConfig) String() string
type OtelConfig ¶
type OtelConfig struct { InstanceID string `cfg:"instance_id"` Trace *TraceConfig `cfg:"trace"` Metrics *MetricsConfig `cfg:"metrics"` }
func (OtelConfig) String ¶
func (c OtelConfig) String() string
type Permissions ¶
type Permissions int
const ( PermissionWrite Permissions = 1 << iota PermissionDelete PermissionWebhook )
type PreviewConfig ¶
type PreviewConfig struct { InkscapePath string `cfg:"inkscape_path"` MaxLines int `cfg:"max_lines"` DPI int `cfg:"dpi"` CacheSize int `cfg:"cache_size"` CacheTTL time.Duration `cfg:"cache_ttl"` }
func (PreviewConfig) String ¶
func (c PreviewConfig) String() string
type RateLimitConfig ¶
type RateLimitConfig struct { Requests int `cfg:"requests"` Duration time.Duration `cfg:"duration"` Whitelist []string `cfg:"whitelist"` Blacklist []string `cfg:"blacklist"` }
func (RateLimitConfig) String ¶
func (c RateLimitConfig) String() string
type RequestFile ¶
type ResponseFile ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) DeleteDocument ¶
func (s *Server) DeleteDocument(w http.ResponseWriter, r *http.Request)
func (*Server) DeleteDocumentWebhook ¶
func (s *Server) DeleteDocumentWebhook(w http.ResponseWriter, r *http.Request)
func (*Server) DocumentVersions ¶
func (s *Server) DocumentVersions(w http.ResponseWriter, r *http.Request)
func (*Server) ExecuteWebhooks ¶
func (s *Server) ExecuteWebhooks(ctx context.Context, event string, document WebhookDocument)
func (*Server) GetDocument ¶
func (s *Server) GetDocument(w http.ResponseWriter, r *http.Request)
func (*Server) GetDocumentFile ¶
func (s *Server) GetDocumentFile(w http.ResponseWriter, r *http.Request)
func (*Server) GetDocumentPreview ¶
func (s *Server) GetDocumentPreview(w http.ResponseWriter, r *http.Request)
func (*Server) GetDocumentWebhook ¶
func (s *Server) GetDocumentWebhook(w http.ResponseWriter, r *http.Request)
func (*Server) GetPrettyDocument ¶
func (s *Server) GetPrettyDocument(w http.ResponseWriter, r *http.Request)
func (*Server) GetRawDocument ¶
func (s *Server) GetRawDocument(w http.ResponseWriter, r *http.Request)
func (*Server) GetRawDocumentFile ¶
func (s *Server) GetRawDocumentFile(w http.ResponseWriter, r *http.Request)
func (*Server) GetVersion ¶
func (s *Server) GetVersion(w http.ResponseWriter, _ *http.Request)
func (*Server) NewToken ¶
func (s *Server) NewToken(documentID string, permissions Permissions) (string, error)
func (*Server) PatchDocument ¶
func (s *Server) PatchDocument(w http.ResponseWriter, r *http.Request)
func (*Server) PatchDocumentWebhook ¶
func (s *Server) PatchDocumentWebhook(w http.ResponseWriter, r *http.Request)
func (*Server) PostDocument ¶
func (s *Server) PostDocument(w http.ResponseWriter, r *http.Request)
func (*Server) PostDocumentShare ¶
func (s *Server) PostDocumentShare(w http.ResponseWriter, r *http.Request)
func (*Server) PostDocumentWebhook ¶
func (s *Server) PostDocumentWebhook(w http.ResponseWriter, r *http.Request)
type ShareRequest ¶
type ShareRequest struct {
}type ShareResponse ¶
type ShareResponse struct {
}type TraceConfig ¶
func (TraceConfig) String ¶
func (c TraceConfig) String() string
type WebhookConfig ¶
type WebhookConfig struct { Timeout time.Duration `cfg:"timeout"` MaxTries int `cfg:"max_tries"` Backoff time.Duration `cfg:"backoff"` BackoffFactor float64 `cfg:"backoff_factor"` MaxBackoff time.Duration `cfg:"max_backoff"` }
func (WebhookConfig) String ¶
func (c WebhookConfig) String() string
type WebhookCreateRequest ¶
type WebhookDocument ¶
type WebhookDocument struct { Key string `json:"key"` Version int64 `json:"version"` Files []WebhookDocumentFile `json:"files"` }
type WebhookDocumentFile ¶
type WebhookEventRequest ¶
type WebhookEventRequest struct { WebhookID string `json:"webhook_id"` Event string `json:"event"` CreatedAt time.Time `json:"created_at"` Document WebhookDocument `json:"document"` }
type WebhookResponse ¶
type WebhookUpdateRequest ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.