copper

package module
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 9 Imported by: 14

README

Copper logo

Go Report Card Go Doc


Copper

Copper is a Go toolkit complete with everything you need to build web apps. It focuses on developer productivity and makes building web apps in Go more fun with less boilerplate and out-of-the-box support for common needs.

🚀 Fullstack Toolkit

Copper provides a toolkit complete with everything you need to build web apps quickly.

📦 One Binary

Build frontend apps along with your backend and ship everything in a single binary.

📝 Server-side HTML

Copper includes utilities that help build web apps with server rendered HTML pages.

💡 Auto Restarts

Copper detects changes and automatically restarts server to save time.

🏗 Scaffolding

Skip boilerplate and scaffold code for your packages, database queries and routes.

🔋 Batteries Included

Includes CLI, lint, dev server, config management, and more!

🔩 First-party packages

Includes packages for authentication, pub/sub, queues, emails, and websockets.


Intro Video (Hacker News Clone)


Getting Started

Head over to the documentation to get started - https://docs.gocopper.dev/

Join us on Discord here - https://discord.gg/fT2AEZyM6A


License

MIT

Documentation

Overview

Package copper encapsulates everything you need to build apps quickly

Index

Constants

This section is empty.

Variables

View Source
var WireModule = wire.NewSet(wire.FieldsOf(new(*App), "Lifecycle", "Config", "Logger"))

WireModule can be used as part of google/wire setup to include the app's lifecycle, config, and logger.

Functions

This section is empty.

Types

type App

type App struct {
	Lifecycle *clifecycle.Lifecycle
	Config    cconfig.Loader
	Logger    clogger.Logger
}

App defines a Copper app container that can run provided code in its managed lifecycle. It provides functionality to read config in multiple environments as defined by command-line flags.

func InitApp

func InitApp() (*App, error)

InitApp creates a new Copper app along with its dependencies.

func New added in v0.3.4

func New() *App

New provides a convenience wrapper around InitApp that logs and exits if there is an error.

func NewApp

func NewApp(lifecycle *clifecycle.Lifecycle, config cconfig.Loader, logger clogger.Logger) *App

NewApp creates a new Copper app and returns it along with the app's lifecycle manager, config, and the logger.

func (*App) Run

func (a *App) Run(fns ...Runner)

Run runs the provided funcs. Once all of the functions complete their run, the lifecycle's stop funcs are also called. If any of the fns return an error, the app exits with an exit code 1. Run should be used when none of the fn are long-running. For long-running funcs like an HTTP server, use Start.

func (*App) Start

func (a *App) Start(fns ...Runner)

Start runs the provided fns and then waits on the OS's INT and TERM signals from the user to exit. Once the signal is received, the lifecycle's stop funcs are called. If any of the fns fail to run and returns an error, the app exits with exit code 1.

type Flags

type Flags struct {
	ConfigPath      cconfig.Path
	ConfigOverrides cconfig.Overrides
}

Flags holds flag values passed in via command line. These can be used to configure the app environment and override the config directory.

func NewFlags

func NewFlags() *Flags

NewFlags reads the command line flags and returns Flags with the values set.

type Runner

type Runner interface {
	Run() error
}

Runner provides an interface that can be run by a Copper app using the Run or Start funcs. This interface is implemented by various packages within Copper including chttp.Server.

Directories

Path Synopsis
Package cconfig provides utilities to read app config files.
Package cconfig provides utilities to read app config files.
cconfigtest
Package cconfigtest provides helper methods to test the cconfig package
Package cconfigtest provides helper methods to test the cconfig package
Package cerrors provides a custom error type that can hold more context than the stdlib error package.
Package cerrors provides a custom error type that can hold more context than the stdlib error package.
Package chttp helps setup a http server with routing, middlewares, and more.
Package chttp helps setup a http server with routing, middlewares, and more.
chttptest
Package chttptest provides utility functions that are useful when testing chttp
Package chttptest provides utility functions that are useful when testing chttp
Package clifecycle provides a Copper app's lifecycle management.
Package clifecycle provides a Copper app's lifecycle management.
Package clogger provides a Logger interface that can be used to log messages and errors
Package clogger provides a Logger interface that can be used to log messages and errors
Package csql helps create and manage database connections
Package csql helps create and manage database connections

Jump to

Keyboard shortcuts

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