Documentation ¶
Index ¶
- Variables
- func GetLogger(ctx context.Context) (*logrus.Entry, error)
- func GetRequestID(ctx context.Context) (string, error)
- func GetResLogEntry(ctx context.Context) (*logrus.Entry, error)
- func LogTime(log *logrus.Entry, name string, start time.Time)
- func NewLogger(log *logrus.Logger) func(next chi.Handler) chi.Handler
- func NewRecoverer(j *JSON) func(next chi.Handler) chi.Handler
- func NewRequestID() func(next chi.Handler) chi.Handler
- func NewSwagger(basePath, scheme string) func(next chi.Handler) chi.Handler
- func NewValidationError(field, err string) error
- type APIError
- type ArangoDBManager
- func (d *ArangoDBManager) Connect(url, name, user, userPassword string) *ArangoDBManager
- func (d *ArangoDBManager) Create(rootUser, rootPassword string) error
- func (d *ArangoDBManager) Drop(rootUser, rootPassword string) error
- func (d *ArangoDBManager) LoadDistantSeed() error
- func (d *ArangoDBManager) LoggerOptions(enabled, printQuery, printResult bool) *ArangoDBManager
- func (d *ArangoDBManager) Migrate() error
- func (d *ArangoDBManager) Run(q arangolite.Runnable) ([]byte, error)
- func (d *ArangoDBManager) SyncSeeds() error
- type Controller
- type CtxKey
- type Handler
- type Interactor
- type JSON
- func (j *JSON) Marshal(l *logrus.Entry, name string, obj interface{}) ([]byte, error)
- func (j *JSON) Render(ctx context.Context, w http.ResponseWriter, status int, object interface{})
- func (j *JSON) RenderError(ctx context.Context, w http.ResponseWriter, status int, apiError APIError, ...)
- func (j *JSON) Unmarshal(l *logrus.Entry, name string, raw []byte, obj interface{}) error
- func (j *JSON) UnmarshalBody(ctx context.Context, w http.ResponseWriter, body io.ReadCloser, ...) bool
- func (j *JSON) UnmarshalBodyBulk(ctx context.Context, w http.ResponseWriter, body io.ReadCloser, ...) (bool, bool)
- type Logger
- type Recoverer
- type Repository
- type RequestID
- type Seed
- type Swagger
- type Timer
- type Validator
Constants ¶
This section is empty.
Variables ¶
View Source
var ( APIJsonRendering = APIError{ Description: "The JSON rendering failed.", ErrorCode: "JSON_RENDERING_ERROR", } APIBodyDecoding = APIError{ Description: "Could not decode the JSON request.", ErrorCode: "BODY_DECODING_ERROR", } )
View Source
var APIInternal = APIError{
Description: "An internal error occured. Please retry later.",
ErrorCode: "INTERNAL_ERROR",
}
Functions ¶
func GetRequestID ¶
GetRequestID returns a request ID from the given context if one is present. Returns the empty string if a request ID cannot be found.
func NewValidationError ¶
Types ¶
type APIError ¶
type APIError struct { // The status code. Status int `json:"status"` // The description of the API error. Description string `json:"description"` // The token uniquely identifying the API error. ErrorCode string `json:"errorCode"` // Additional infos. Params map[string]interface{} `json:"params,omitempty"` }
APIError defines a standard format for API errors.
type ArangoDBManager ¶
type ArangoDBManager struct {
URL, Name string
User, UserPassword string
// contains filtered or unexported fields
}
func NewArangoDBManager ¶
func NewArangoDBManager(localSeed, distantSeed Seed) *ArangoDBManager
func (*ArangoDBManager) Connect ¶
func (d *ArangoDBManager) Connect(url, name, user, userPassword string) *ArangoDBManager
func (*ArangoDBManager) Create ¶
func (d *ArangoDBManager) Create(rootUser, rootPassword string) error
func (*ArangoDBManager) Drop ¶
func (d *ArangoDBManager) Drop(rootUser, rootPassword string) error
func (*ArangoDBManager) LoadDistantSeed ¶
func (d *ArangoDBManager) LoadDistantSeed() error
func (*ArangoDBManager) LoggerOptions ¶
func (d *ArangoDBManager) LoggerOptions(enabled, printQuery, printResult bool) *ArangoDBManager
func (*ArangoDBManager) Migrate ¶
func (d *ArangoDBManager) Migrate() error
func (*ArangoDBManager) Run ¶
func (d *ArangoDBManager) Run(q arangolite.Runnable) ([]byte, error)
func (*ArangoDBManager) SyncSeeds ¶
func (d *ArangoDBManager) SyncSeeds() error
type Controller ¶
func NewController ¶
type Interactor ¶
func NewInteractor ¶
func NewInteractor( c *viper.Viper, l *logrus.Entry, ) *Interactor
type JSON ¶
type JSON struct{}
func (*JSON) RenderError ¶
func (*JSON) UnmarshalBody ¶
func (j *JSON) UnmarshalBody( ctx context.Context, w http.ResponseWriter, body io.ReadCloser, obj interface{}, ) bool
func (*JSON) UnmarshalBodyBulk ¶
func (j *JSON) UnmarshalBodyBulk( ctx context.Context, w http.ResponseWriter, body io.ReadCloser, objSlice interface{}, ) (bool, bool)
type Repository ¶
func NewRepository ¶
type RequestID ¶
type RequestID struct{}
RequestID is a middleware that injects a request ID into the context of each request. A request ID is a string of the form "host.example.com/random-0001", where "random" is a base62 random string that uniquely identifies this go process, and where the last number is an atomically incremented request counter.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.