Documentation
¶
Overview ¶
Package fire implements a small and opinionated framework for Go providing Ember compatible JSON APIs.
Index ¶
- type Application
- func (a *Application) Components() []Component
- func (a *Application) Exec(fn func() error)
- func (a *Application) Mount(component Component)
- func (a *Application) Report(err error)
- func (a *Application) Router() *echo.Echo
- func (a *Application) Start(addr string)
- func (a *Application) StartSecure(addr, certFile, keyFile string)
- func (a *Application) StartWith(server engine.Server)
- func (a *Application) Stop()
- func (a *Application) Yield()
- type BootableComponent
- type Component
- type ComponentInfo
- type Inspector
- type InspectorComponent
- type Map
- type Phase
- type Reporter
- type ReporterComponent
- type RoutableComponent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct {
// contains filtered or unexported fields
}
An Application provides a simple way to combine multiple components.
func (*Application) Components ¶
func (a *Application) Components() []Component
Components will return all so far registered components.
func (*Application) Exec ¶
func (a *Application) Exec(fn func() error)
Exec will execute the passed function and report any potential errors.
See: Report.
func (*Application) Mount ¶
func (a *Application) Mount(component Component)
Mount will mount the passed Component in the application.
Note: Each component should only be mounted once before calling Run or Start.
func (*Application) Report ¶
func (a *Application) Report(err error)
Report will report the passed error using all mounted reporter components.
Note: If a reporter fails to report an occurring error, the current goroutine will panic and print the original error and the reporter's error.
func (*Application) Router ¶
func (a *Application) Router() *echo.Echo
Router returns the used echo router for this application.
func (*Application) Start ¶
func (a *Application) Start(addr string)
Start will start the application using a new server listening on the specified address.
See StartWith.
func (*Application) StartSecure ¶
func (a *Application) StartSecure(addr, certFile, keyFile string)
StartSecure will start the application with a new server listening on the specified address using the provided TLS certificate.
See StartWith.
func (*Application) StartWith ¶
func (a *Application) StartWith(server engine.Server)
StartWith will start the application using the specified server.
Note: Any errors that occur during the boot process of the application and later during request processing are reported using the registered reporters. If there are no reporters or one of the reporter fails to report the error, the calling goroutine will panic and print the error (see Exec).
func (*Application) Stop ¶
func (a *Application) Stop()
Stop will stop a running application and wait until it has been properly stopped.
func (*Application) Yield ¶
func (a *Application) Yield()
Yield will block the calling goroutine until the the application has been stopped. It will automatically stop the application if the process receives the SIGINT signal.
type BootableComponent ¶
type BootableComponent interface {
Component
// Setup will be called before the applications starts and allows further
// initialization.
Setup() error
// Teardown will be called after applications has stopped and allows proper
// cleanup.
Teardown() error
}
A BootableComponent is an extended component with additional methods for setup and teardown.
type Component ¶
type Component interface {
// Describe must return a ComponentInfo struct that describes the component.
Describe() ComponentInfo
}
A Component that can be mounted in an application.
type ComponentInfo ¶
type ComponentInfo struct {
// The name of the component.
Name string
// The settings it is using.
Settings Map
}
A ComponentInfo is returned by a component to describe itself.
type Inspector ¶
An Inspector can be used during development to print the applications component stack, the route table and log requests to writer.
func DefaultInspector ¶
func DefaultInspector() *Inspector
DefaultInspector creates and returns a new inspector that writes to stdout.
func NewInspector ¶
NewInspector creates and returns a new inspector.
func (*Inspector) Before ¶
func (i *Inspector) Before(stage Phase, app *Application)
Before implements the InspectorComponent interface.
func (*Inspector) Describe ¶
func (i *Inspector) Describe() ComponentInfo
Describe implements the Component interface.
type InspectorComponent ¶
type InspectorComponent interface {
Component
// Before is called by the application before the specified phase is
// initiated by the passed application.
Before(phase Phase, app *Application)
}
An InspectorComponent is an extended component that is able to inspect the boot process of an application and inspect all used components and the router instance.
type Phase ¶
type Phase int
A Phase is used in conjunction with a InspectorComponent and denotes a phase the application will undergo.
const ( // Registration is the phase in which components get registered. Registration Phase = iota // Setup is the phase in which components get set up. Setup // Run is the phase in which the application handles requests. Run // Teardown is the phase in which components get teared down. Teardown // Termination is the phase in which the applications is terminated. Termination )
type Reporter ¶
A Reporter can be used write errors occurring during request to a writer.
func DefaultReporter ¶
func DefaultReporter() *Reporter
DefaultReporter creates and returns a reporter that writes errors to stderr.
func NewReporter ¶
NewReporter create and returns a new reporter writing to the specified writer.
func (*Reporter) Describe ¶
func (r *Reporter) Describe() ComponentInfo
Describe implements the Component interface.
type ReporterComponent ¶
type ReporterComponent interface {
Component
// Report is called by the application on every occurring error.
Report(err error) error
}
A ReporterComponent is an extended component that is responsible for reporting errors.
type RoutableComponent ¶
type RoutableComponent interface {
Component
// Register will be called by the application with a new echo router.
Register(router *echo.Echo)
}
A RoutableComponent is a component that accepts requests from a router for routes that haven been registered using Register().
Directories
¶
| Path | Synopsis |
|---|---|
|
Package components contains additional components which can be mounted in a fire application.
|
Package components contains additional components which can be mounted in a fire application. |
|
Package jsonapi implements components to build JSON APIs with fire.
|
Package jsonapi implements components to build JSON APIs with fire. |
|
Package model implements a basic model abstraction for structs.
|
Package model implements a basic model abstraction for structs. |
|
Package oauth2 implements an authenticator component that provides OAuth2 compatible authentication.
|
Package oauth2 implements an authenticator component that provides OAuth2 compatible authentication. |