internal

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSearchProvider = "https://duckduckgo.com/%s"
)

Variables

View Source
var (
	ErrUnrecognizedCommand = errors.New("unrecognized command")
	ErrNotEnoughArguments  = errors.New("not enough arguments")
)

Functions

func NewServer

func NewServer(tp TemplateRenderer, shortcutStore *ShortcutStore, accessLogging bool) http.Handler

Types

type Command

type Command struct {
	Action   string
	Name     string
	Location string
}

type CommandHandler

type CommandHandler struct {
	*sync.Mutex
	Shortcuts map[string]string
}

func (*CommandHandler) Handle

func (c *CommandHandler) Handle(input string) (Command, error)

type ShortcutData added in v0.2.1

type ShortcutData struct {
	Shortcuts Shortcuts `json:"shortcuts"`
}

type ShortcutStore added in v0.2.1

type ShortcutStore struct {
	Path string
}

func (*ShortcutStore) Init added in v0.2.1

func (ss *ShortcutStore) Init() error

func (*ShortcutStore) LoadShortcuts added in v0.2.1

func (ss *ShortcutStore) LoadShortcuts(copyTo io.Writer) (Shortcuts, error)

func (*ShortcutStore) SaveShortcuts added in v0.2.1

func (ss *ShortcutStore) SaveShortcuts(shorts Shortcuts, copyTo io.Writer) error

type Shortcuts added in v0.2.1

type Shortcuts map[string]string

func NewDefaultShortcuts added in v0.2.1

func NewDefaultShortcuts() Shortcuts

type TemplateRenderer

type TemplateRenderer struct {
	FS http.FileSystem
}

func (TemplateRenderer) Render

func (tr TemplateRenderer) Render(name string, templVars TemplateVariables, w io.Writer) error

func (TemplateRenderer) RenderHandler

func (tr TemplateRenderer) RenderHandler(filename string, ss *CommandHandler, headers http.Header) http.HandlerFunc

type TemplateVariables

type TemplateVariables struct {
	Host    string
	Entries map[string]string
}

func ToTemplateVars

func ToTemplateVars(req *http.Request, shortcuts map[string]string) TemplateVariables

Jump to

Keyboard shortcuts

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