Documentation
¶
Overview ¶
Copyright (C) 2024 early (MIT)
Copyright (C) 2024 early (MIT)
Copyright (C) 2024 early (MIT)
Index ¶
- Constants
- func AppendEnv(vars []string, env Env) []string
- type AcceptsEnv
- type App
- func (app *App) Handle(expr string, handler http.Handler)
- func (app *App) ListenAndServe() error
- func (app *App) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (app *App) Shutdown(ctx context.Context) error
- func (app *App) ShutdownOnSignal(sigs ...os.Signal)
- func (app *App) Static(rootPath, rootDir string) error
- func (app *App) Subprocess(process func(done <-chan struct{}) error)
- type Env
Constants ¶
View Source
const ( ENV_APP_NAME = "APP_NAME" ENV_LISTEN_HTTP = "LISTEN_HTTP" ENV_LOG_LEVEL = "LOG_LEVEL" )
Variables ¶
This section is empty.
Functions ¶
func AppendEnv ¶
AppendEnv appends the env as key=value pairs to a list of vars. This is intended for use with os.Environ() to pass environments to subprocesses:
cmd := exec.Command(...) osEnv := os.Environ() subprocessEnv := app.Env{...} osEnv = app.AppendEnv(osEnv, subprocessEnv) cmd.Exec()
Types ¶
type App ¶
type App struct { http.Server http.ServeMux Logger *slog.Logger // contains filtered or unexported fields }
func (*App) ShutdownOnSignal ¶
ShutdownOnSignal will start the process of an app shutting down if an OS signal is received.
func (*App) Static ¶
Static serves the files in rootDir at rootPath.
- .html files have their extensions stripped, and are served as their filenames, following a directory structure. If there is an index.html in a directory, it is served under the directory name, with a trailing slash, so /foo/bar/index.html is served at /foo/bar/.
- Other non-excluded files are served with their extensions intact. Currently, .go files and anything in a hidden directory are excluded. MIME types are chosen by Go's standard HTTP library behavior until that becomes a pain.
- If using today-engine, page.New and page.Static will *override* the default behavior of Static. *This is only possible when using today-engine.*
- If static is called twice for the same rootPath, the second call will override the first.
Click to show internal directories.
Click to hide internal directories.