Categorygithub.com/256dpi/fire
modulepackage
0.34.4
Repository: https://github.com/256dpi/fire.git
Documentation: pkg.go.dev

# README

Logo

Go on Fire

Test GoDoc Release

An idiomatic micro-framework for building Ember.js compatible APIs with Go.

Introduction

Go on Fire is built on top of the wonderful built-in http package, implements the JSON API specification through the dedicated jsonapi library, uses the official mongo driver for persisting resources with MongoDB, and leverages the dedicated oauth2 library to provide out-of-the-box support for OAuth2 authentication using JWT tokens. Additionally, it provides packages for request authorization, asynchronous job processing, and WebSocket-based event sourcing.

The deliberate and tight integration of these components provides a very simple and extensible set of abstractions for rapidly building backend services for websites that use Ember.js as their frontend framework. Of course, it can also be used in conjunction with any other single-page application framework or as a backend for native mobile applications.

To get started with building with Go on Fire, refer to the package documentation for more detailed information on the types and methods. Also, have a look at the example application that uses most Go on Fire features.

Features

Go on Fire ships with built-in support for various features to provide a complete toolkit for ambitious projects:

  • Declarative definition of models and resource controllers.
  • Custom group, collection, and resource actions.
  • Built-in validators incl. automatic relationship validation.
  • Callback-based plugin system for easy extendability.
  • Integrated asynchronous and distributed job processing system.
  • Event sourcing via WebSockets and SSE.
  • Declarative authentication and authorization framework.
  • Integrated OAuth2 authenticator and authorizer.
  • Support for tracing via opentracing.

Installation

To get started, install the package using the go tool:

$ go get -u github.com/256dpi/fire

License

The MIT License (MIT)

Copyright (c) 2016 Joël Gähwiler

# Packages

Package ash implements a highly configurable and callback based ACL that can be used to authorize controller operations in a declarative way.
No description provided by the author
No description provided by the author
Package coal provides a mini ORM for mongoDB.
No description provided by the author
Package flame implements an authenticator that provides OAuth2 compatible authentication with JWT tokens.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

A is a shorthand function to construct an action.
All will match all contexts.
AssignResource will assign the provided resource to the specified model.
BasicAuthorizer authorizes requests based on a simple credentials list.
C is a shorthand function to construct a callback.
ClientFor creates a model specific client for the specified model using the provided generic client.
Combine will combine multiple callbacks.
ConvertModel will convert the provided model to a resource.
DependentResourcesValidator counts related documents and returns an error if some are found.
Except will match if the operation is not present in the provided list.
MatchingReferencesValidator compares the model with one related model or all related models and checks if the specified references are shared exactly.
NewClient will create and return a new client.
NewGroup creates and returns a new group.
NewTester returns a new tester.
Only will match if the operation is present in the provided list.
P is a shorthand to look up the specified property method on the provided model.
ProtectedFieldsValidator compares protected fields against their default during Create (if provided) or stored value during Update and returns an error if they have been changed.
ReferencedResourcesValidator makes sure all references in the document are existing by counting the referenced documents.
RelationshipValidator makes sure all relationships of a model are correct and in place.
TimestampModifier will set timestamp fields on create and update operations.

# Constants

The available controller callback stages.
CollectionAction operation will be used to authorize the execution of a callback for a collection action.
Create operation will be used to authorize and validate the creation of a new resource in a collection.
The available controller callback stages.
Delete operation will be used to authorize the loading and validate the deletion of a specific resource in a collection.
Find operation will be used to authorize the loading of a specific resource from a collection.
List operation will be used to authorize the loading of multiple resources from a collection.
The available controller callback stages.
NoDefault marks the specified field to have no default that needs to be enforced while executing the ProtectedFieldsValidator.
The available controller callback stages.
ResourceAction operation will be used to authorize the execution of a callback for a resource action.
Update operation will be used to authorize the loading and validate the updating of a specific resource in a collection.
The available controller callback stages.
The available controller callback stages.

# Variables

ErrAccessDenied may be returned to indicate unauthorized access.
ErrDocumentNotUnique may be returned if a provided document does not satisfy the required uniqueness constraints.
ErrResourceNotFound may be returned to indicate a missing resource.

# Structs

An Action defines a collection or resource action.
A Callback is called during the request processing flow of a controller.
Client wraps a jsonapi.Client to directly interact with models.
Context carries the state of a request and allows callbacks to influence the processing of a request.
A Controller provides a JSON API based interface to a model.
A Group manages access to multiple controllers and their interconnections.
GroupAction defines a group action.
ModelClient is model specific client.
A Tester provides facilities to the test a fire API.

# Type aliases

FilterHandler defines a function that turns filter values into a filter expression.
Handler is function that takes a context, mutates is to modify the behaviour and response or return an error.
L is a shorthand type to create a list of callbacks.
M is a shorthand type to create a map of actions.
Matcher is a function that makes an assessment of a context and decides whether an operation should be allowed to be carried out.
An Operation indicates the purpose of a yield to a callback in the processing flow of an API request by a controller.
Stage defines a controller callback stage.