cms

package module
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: MIT Imports: 6 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ResourceCtxKey  = &contextKey{"Resource"}
	DirectoryCtxKey = &contextKey{"Directory"}
)

Functions

func DefaultGetRoutePath added in v0.5.0

func DefaultGetRoutePath(r *http.Request) string

func DefaultSetDirectory added in v0.7.0

func DefaultSetDirectory(ctx context.Context, dir Directory) context.Context

func DefaultSetResource added in v0.5.0

func DefaultSetResource(ctx context.Context, res Resource) context.Context

Types

type CreatableResource

type CreatableResource interface {
	Resource
	Put(http.ResponseWriter, *http.Request) error
}

PUT

type DeletableResource

type DeletableResource interface {
	Resource
	Delete(http.ResponseWriter, *http.Request) error
}

DELETE

type Directory added in v0.0.6

type Directory interface {
	fs.DirEntry
	fs.FileInfo

	Path() string

	Chdir(string) (Directory, error)
	MkdirAll(string) (Directory, error)

	Open(string) (Resource, error)
}

func DefaultGetDirectory added in v0.7.0

func DefaultGetDirectory(ctx context.Context) Directory

type PeekableResource

type PeekableResource interface {
	Resource
	Head(w http.ResponseWriter, r *http.Request) error
}

HEAD

type Resource

type Resource interface {
	MimeTypes() []string
	Get(http.ResponseWriter, *http.Request) error
}

GET

func DefaultGetResource added in v0.5.0

func DefaultGetResource(ctx context.Context) Resource

type Server

type Server interface {
	View(path string) View

	Chdir(string) (Directory, error)
	MkdirAll(string) (Directory, error)
	Chroot(string) (Directory, error)
}

type SubmitableResource

type SubmitableResource interface {
	Resource
	Post(http.ResponseWriter, *http.Request) error
}

POST

type User added in v0.0.2

type User interface {
	Username() string
	CanDo(c UserCapability, r Resource) bool
	CanDoPath(c UserCapability, path string) bool
}

func DefaultGetUser added in v0.5.0

func DefaultGetUser(ctx context.Context) User

type UserCapability added in v0.0.2

type UserCapability int
const (
	CanRead UserCapability = iota
	CanWrite
	CanPurge
)

type View added in v0.0.2

type View interface {
	http.Handler
	web.Handler
	web.RouterPageInfo

	Middleware(prefix string) func(next http.Handler) http.Handler

	Config() *ViewConfig
}

type ViewConfig added in v0.0.2

type ViewConfig struct {
	GetRoutePath func(r *http.Request) string
	GetUser      func(ctx context.Context) User
	SetResource  func(ctx context.Context, res Resource) context.Context
	GetResource  func(ctx context.Context) Resource
	SetDirectory func(ctx context.Context, res Directory) context.Context
	GetDirectory func(ctx context.Context) Directory

	Edit           string // per resource
	EditHandler    web.HandlerFunc
	Files          string // per directory
	FilesHandler   web.HandlerFunc
	Ping           string // optional per view
	PingHandler    web.HandlerFunc
	Sitemap        string // optional per view
	SitemapHandler web.HandlerFunc

	ErrorHandler web.ErrorHandlerFunc

	Index    string // default page
	ReadOnly bool   // storage can't be modified through this View
}

func (*ViewConfig) SetDefaults added in v0.0.2

func (c *ViewConfig) SetDefaults() error

Defaults

func (*ViewConfig) SetEditHandler added in v0.0.3

func (c *ViewConfig) SetEditHandler(path string, handler web.HandlerFunc) error

Set View's File Editor

func (*ViewConfig) SetErrorHandler added in v0.5.0

func (c *ViewConfig) SetErrorHandler(f web.ErrorHandlerFunc) error

func (*ViewConfig) SetFilesHandler added in v0.0.3

func (c *ViewConfig) SetFilesHandler(path string, handler web.HandlerFunc) error

Set View's File Manager

func (*ViewConfig) SetGetDirectory added in v0.7.0

func (c *ViewConfig) SetGetDirectory(f func(ctx context.Context) Directory) error

Get Directory from context.Context

func (*ViewConfig) SetGetResource added in v0.5.0

func (c *ViewConfig) SetGetResource(f func(ctx context.Context) Resource) error

Get Resource from context.Context

func (*ViewConfig) SetGetRoutePath added in v0.5.0

func (c *ViewConfig) SetGetRoutePath(f func(*http.Request) string) error

func (*ViewConfig) SetGetUser added in v0.5.0

func (c *ViewConfig) SetGetUser(f func(ctx context.Context) User) error

func (*ViewConfig) SetIndexPage added in v0.5.0

func (c *ViewConfig) SetIndexPage(index string) error

func (*ViewConfig) SetPingHandler added in v0.0.3

func (c *ViewConfig) SetPingHandler(path string, handler web.HandlerFunc) error

Set View's Ping Handler

func (*ViewConfig) SetSetDirectory added in v0.7.0

func (c *ViewConfig) SetSetDirectory(f func(ctx context.Context, res Directory) context.Context) error

Put Directory into context.Context

func (*ViewConfig) SetSetResource added in v0.5.0

func (c *ViewConfig) SetSetResource(f func(ctx context.Context, res Resource) context.Context) error

Put Resource into context.Context

func (*ViewConfig) SetSitemapHandler added in v0.0.3

func (c *ViewConfig) SetSitemapHandler(path string, handler web.HandlerFunc) error

Set View's Sitemap Handler

Directories

Path Synopsis
os

Jump to

Keyboard shortcuts

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