toolbag

package module
v0.0.0-...-5450b70 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2021 License: AGPL-3.0 Imports: 4 Imported by: 1

README

toolbag

This repository holds the source for some Go utilities I use on my website. You can find a listing here. Just for kicks, I've licensed them under the AGPLv3.

notfound and figlet are probably the most fun. The former requires texlive, and the latter requires figlet and my code.austinjadams.com/execd package.

how the figlet tool works

where <---> is a socket and ==> indicates executing another program:

in production
(internet)
    ^
    | tcp :80, :443
    v
  nginx
    ^
    | fastcgi (unix socket)
    |            ___________________
    v           |                   |
 toolbag<-------|-->execd => figlet |
           tcp  |___________________|
               systemd-nspawn container

For more information on the systemd-nspawn container, see the figlet README in my execd repository.

in development
./run => execd => figlet
  ||       ^
  ||       | tcp
  ||       v
  |====> toolbag<----------->your browser
                  tcp :8030

trying it out

to try toolbag:

# apt-get install figlet texlive
$ go get code.austinjadams.com/toolbag
$ go get code.austinjadams.com/execd
$ cd $GOPATH/src/code.austinjadams.com/execd/execd
$ go build
$ cd $GOPATH/src/code.austinjadams.com/toolbag/toolbag
$ go build
$ pushd share
$ make
$ popd
$ ./run
$ firefox localhost:8030/tools

or, in words:

  1. install figlet, which the figlet tool requires, and a compatible latex distribution (probably just texlive), which you'll need for building the notfound images
  2. use go get (or plain git or whatever) to download code.austinjadams.com/toolbag and /execd. (execd is a dependency of the figlet tool. unfortunately, go get doesn't seem to understand the dependencies of subpackages, so you'll have to retrieve it by hand.)
  3. go build code.austinjadams.com/execd/execd and code.austinjadams.com/toolbag/toolbag (these are not typos -- the binaries are sub-packages)
  4. run the Makefile in the tools/share directory (toolbag/share, a symlink, points there)
  5. from /toolbag, call the run shellscript to start a minimal http server and an execd server.
  6. make http requests to localhost:8030 to enjoy life

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Arg

func Arg(t Tool, argname string) string

just a way to compose names of flags

func LogWhine

func LogWhine(t Tool, err error)

func LogWhineString

func LogWhineString(t Tool, msg string)

for when WriteHeader() has already been called (e.g., template errors)

func PrependToolName

func PrependToolName(t Tool, err error) error

stick the name of a tool before an error message

func Whine

func Whine(t Tool, w http.ResponseWriter, err error)

func WhineString

func WhineString(t Tool, w http.ResponseWriter, msg string)

Types

type Tool

type Tool interface {
	Name() string
	Desc() string
	Path() string
	AddArgs(*ToolBag)
	Init() error
	http.Handler
}

type ToolBag

type ToolBag struct {
	Tools []Tool
	*http.ServeMux
	*flag.FlagSet
}

func NewToolBag

func NewToolBag(tools ...Tool) *ToolBag

func (*ToolBag) Init

func (tb *ToolBag) Init() error

type ToolFunc

type ToolFunc struct {
	http.HandlerFunc
	// contains filtered or unexported fields
}

func NewToolFunc

func NewToolFunc(name, desc string, f http.HandlerFunc) *ToolFunc

func NewToolFuncAt

func NewToolFuncAt(name, desc, path string, f http.HandlerFunc) *ToolFunc

func (*ToolFunc) AddArgs

func (ft *ToolFunc) AddArgs(*ToolBag)

func (*ToolFunc) Desc

func (ft *ToolFunc) Desc() string

func (*ToolFunc) Init

func (ft *ToolFunc) Init() error

func (*ToolFunc) Name

func (ft *ToolFunc) Name() string

func (*ToolFunc) Path

func (ft *ToolFunc) Path() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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