# README
Casket
Casket is a fork of mholt's Caddy web server v1. Its goal is to maintain Caddy's original goal of being a straight forward, simple to use web server rather than the direction of Caddy v2 which has a focus on microservices and programmatic configurability.
Casket will come with all the features you love about Caddy v1, while also adding our own touches for convenience and usability.
Building
To build the main casket executable, the following procedure can be used:
git clone https://github.com/tmpim/casket
cd casket
go build -o ./build/casket ./casket
# The executable can now be found at ./build/casket
Note these development builds will lack version information and will report a version of (devel). You can also instead create a snapshot build using the following procedure:
go install github.com/goreleaser/goreleaser@latest # Install goreleaser
goreleaser build --snapshot --rm-dist --single-target --id casket # Create a snapshot build
# The executable can now be found at ./build/casket_linux_amd64/casket
Docker
A docker image is provided for the latest version of Casket from ghcr.io/tmpim/casket
.
Example using docker-compose
:
version: "3.8"
services:
casket:
image: ghcr.io/tmpim/casket:latest # or a specific version like v1.2
restart: unless-stopped
ports:
- "80:80" # HTTP
- "443:443" # HTTPS
volumes:
- ./Casketfile:/config/Casketfile # Pass in your casket config
- ./static:/www # Pass in your static content
- casket_data:/data # Create a volume to store persistent data (e.g. certificates)
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
Package caskettls facilitates the management of TLS assets and integrates Let's Encrypt functionality into Casket with first-class support for creating and renewing certificates automatically.
No description provided by the author
# Functions
AssetsPath returns the path to the folder where the application may store data.
CasketfileFromPipe loads the Casketfile input from f if f is not interactive input.
DefaultInput returns the default Casketfile input to use when it is otherwise empty or missing.
DescribePlugins returns a string describing the registered plugins.
DirectiveAction gets the action for directive dir of server type serverType.
EmitEvent executes the different hooks passing the EventType as an argument.
Instances returns the list of instances.
IsInternal returns true if the IP of addr belongs to a private network IP range.
IsLoopback returns true if the hostname of addr looks explicitly like a common local hostname.
IsUpgrade returns true if this process is part of an upgrade where a parent casket process spawned this one to upgrade the binary.
ListPlugins makes a list of the registered plugins, keyed by plugin type.
LoadCasketfile loads a Casketfile by calling the plugged in Casketfile loader methods.
NewTestController creates a new Controller for the server type and input specified.
RegisterCasketfileLoader registers loader named name.
RegisterEventHook plugs in hook.
RegisterParsingCallback registers callback to be called after executing the directive afterDir for server type serverType.
RegisterPlugin plugs in plugin.
RegisterServerType registers a server type srv by its name, typeName.
SetDefaultCasketfileLoader registers loader by name as the default Casketfile loader if no others produce a Casketfile.
SplitCommandAndArgs takes a command string and parses it shell-style into the command and its separate arguments.
Start starts Casket with the given Casketfile.
Started returns true if at least one instance has been started by this package.
Stop stops ALL servers.
TrapSignals create signal handlers for all applicable signals for this system.
Upgrade re-launches the process, preserving the listeners for a graceful upgrade.
ValidateAndExecuteDirectives will load the server blocks from cdyfile by parsing it, then execute the directives configured by it and store the resulting server blocks into inst.
ValidDirectives returns the list of all directives that are recognized for the server type serverType.
# Constants
Define names for the various events.
Define names for the various events.
Define names for the various events.
Define names for the various events.
Define names for the various events.
# Variables
AppName is the name of the application.
AppVersion is the version of the application.
DefaultConfigFile is the name of the configuration file that is loaded by default if no other file is specified.
GracefulTimeout is the maximum duration of a graceful shutdown.
OnProcessExit is a list of functions to run when the process exits -- they are ONLY for cleanup and should not block, return errors, or do anything fancy.
PidFile is the path to the pidfile to create.
Quiet mode will not show any informative output on initialization.
# Structs
CasketfileInput represents a Casketfile as input and is simply a convenient way to implement the Input interface.
Controller is given to the setup function of directives which gives them access to be able to read tokens with which to configure themselves.
Instance contains the state of servers created as a result of calling Start and can be used to access or control those servers.
Plugin is a type which holds information about a plugin.
ServerListener pairs a server to its listener and/or packetconn.
ServerType contains information about a server type.
# Interfaces
AfterStartup is an interface that can be implemented by a server type that wants to run some code after all servers for the same Instance have started.
Context is a type which carries a server type through the load and setup phase; it maintains the state between loading the Casketfile, then executing its directives, then making the servers for Casket to manage.
GracefulServer is a Server and Stopper, the stopping of which is graceful (whatever that means for the kind of server being implemented).
Input represents a Casketfile; its contents and file path (which should include the file name at the end of the path).
Listener is a net.Listener with an underlying file descriptor.
Loader is a type that can load a Casketfile.
PacketConn is a net.PacketConn with an underlying file descriptor.
Server is a type that can listen and serve.
Stopper is a type that can stop serving.
TCPServer is a type that can listen and serve connections.
UDPServer is a type that can listen and serve packets.
# Type aliases
CtxKey is a value type for use with context.WithValue.
EventHook is a type which holds information about a startup hook plugin.
EventName represents the name of an event used with event hooks.
LoaderFunc is a convenience type similar to http.HandlerFunc that allows you to use a plain function as a Load() method.
ParsingCallback is a function that is called after a directive's setup functions have been executed for all the server blocks.
SetupFunc is used to set up a plugin, or in other words, execute a directive.