webconnector

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultBaseDir       = `C:\Documents\psrt`
	DefaultAllowedOrigin = "https://editor.psrt.app"
	DefaultPort          = 5278
)
View Source
const Version = "1.0.0"

Variables

This section is empty.

Functions

func DecodeJSON

func DecodeJSON(w http.ResponseWriter, r *http.Request, dst any) bool

func DecodeJSONMethod

func DecodeJSONMethod(w http.ResponseWriter, r *http.Request, method string, dst any) bool

func IsAllowedImageMIME

func IsAllowedImageMIME(mime string) bool

func ResolveWithinBase

func ResolveWithinBase(baseDir, rawPath string) (string, error)

func RunTray

func RunTray(_ *Server, _ string, _ bool)

RunTray is a no-op on non-Windows platforms.

func WithStrictCORS

func WithStrictCORS(s *Server, next http.Handler) http.Handler

func WriteErr

func WriteErr(w http.ResponseWriter, status int, err error)

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, v any)

Types

type AdaptEntriesReq

type AdaptEntriesReq struct {
	EntriesJSON string  `json:"entriesJSON"`
	CanvasW     int     `json:"canvasW"`
	CanvasH     int     `json:"canvasH"`
	Zoom        float64 `json:"zoom"`
}

type AssetURIReq

type AssetURIReq struct {
	URL string `json:"url"`
}

type Audit

type Audit struct{}

func NewAudit

func NewAudit() *Audit

func (*Audit) AuthFailure

func (a *Audit) AuthFailure(path, remote string)

func (*Audit) ConfigReloaded

func (a *Audit) ConfigReloaded(configPath string, portChanged bool)

func (*Audit) ConfigUpdated

func (a *Audit) ConfigUpdated(fields []string)

func (*Audit) MimeRejected

func (a *Audit) MimeRejected(path, mime, remote string)

func (*Audit) OriginRejected

func (a *Audit) OriginRejected(origin, path string)

func (*Audit) PairCodeRefreshed

func (a *Audit) PairCodeRefreshed()

func (*Audit) PairFailure

func (a *Audit) PairFailure(origin, remote string)

func (*Audit) PairSuccess

func (a *Audit) PairSuccess(origin, remote string)

func (*Audit) SandboxViolation

func (a *Audit) SandboxViolation(path, remote string)

func (*Audit) Startup

func (a *Audit) Startup(addr, baseDir, allowedOrigin string)

type Auth

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

func NewAuth

func NewAuth(audit *Audit) *Auth

func (*Auth) Pair

func (a *Auth) Pair(code, origin, remote string) (string, bool)

func (*Auth) PairCodeForDisplay

func (a *Auth) PairCodeForDisplay() string

func (*Auth) PairUntil

func (a *Auth) PairUntil() time.Time

func (*Auth) RefreshPairCode

func (a *Auth) RefreshPairCode() string

func (*Auth) ValidateToken

func (a *Auth) ValidateToken(token string) bool

type CompileReq

type CompileReq struct {
	DocJSON  string `json:"docJSON"`
	PageName string `json:"pageName"`
}

type Config

type Config struct {
	BaseDir       string
	AllowedOrigin string
	Port          int
}

func DefaultConfig

func DefaultConfig() *Config

func LoadConfig

func LoadConfig(path string) (*Config, error)

func LoadOrCreateConfig

func LoadOrCreateConfig(path string) (*Config, error)

LoadOrCreateConfig loads the INI at path, creating a default config (and its base_dir) when the file does not exist yet — e.g. first run of the binary.

func (*Config) Clone

func (c *Config) Clone() *Config

func (*Config) NormalizeBaseDir

func (c *Config) NormalizeBaseDir() error

func (*Config) Save

func (c *Config) Save(path string) error

func (*Config) Validate

func (c *Config) Validate() error

type DocJSONReq

type DocJSONReq struct {
	DocJSON string `json:"docJSON"`
}

type ImageAsset

type ImageAsset struct {
	Bytes []byte
	MIME  string
}

func ReadAllowedImage

func ReadAllowedImage(path string) (ImageAsset, error)

type LibraryProject

type LibraryProject struct {
	Path       string `json:"path"`
	Title      string `json:"title"`
	PageCount  int    `json:"pageCount"`
	ModifiedAt string `json:"modifiedAt"`
}

type LibraryProjectsResponse

type LibraryProjectsResponse struct {
	Projects []LibraryProject `json:"projects"`
}

type MIMEError

type MIMEError struct {
	MIME string
}

func (*MIMEError) Error

func (e *MIMEError) Error() string

type MergePageReq

type MergePageReq struct {
	FullDocJSON string `json:"fullDocJSON"`
	PageName    string `json:"pageName"`
	PsrtText    string `json:"psrtText"`
}

type SandboxError

type SandboxError struct {
	Requested string
	Base      string
}

func (*SandboxError) Error

func (e *SandboxError) Error() string

type Server

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

func NewServer

func NewServer(configPath string, cfg *Config, audit *Audit) *Server

func (*Server) AllowedOrigin

func (s *Server) AllowedOrigin() string

func (*Server) Auth

func (s *Server) Auth() *Auth

func (*Server) BaseDir

func (s *Server) BaseDir() string

func (*Server) Config

func (s *Server) Config() *Config

func (*Server) ConfigPath

func (s *Server) ConfigPath() string

func (*Server) Handler

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

func (*Server) IsOriginAllowed

func (s *Server) IsOriginAllowed(origin string) bool

func (*Server) RegisterRoutes

func (s *Server) RegisterRoutes(mux *http.ServeMux)

func (*Server) ReloadConfig

func (s *Server) ReloadConfig() error

func (*Server) UpdateConfig

func (s *Server) UpdateConfig(next *Config) error

Jump to

Keyboard shortcuts

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