server

package
v0.0.0-...-e1d1ae0 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package server implements the Jurassic Park Admin API server.

Index

Constants

View Source
const Prefix = "/api/v1"

Variables

This section is empty.

Functions

func LoggerMiddleware

func LoggerMiddleware(logger logrus.FieldLogger, now func() time.Time, timeFormat string, utc bool) gin.HandlerFunc

LoggerMiddleware returns a gin.HandlerFunc (middleware) that logs requests using logrus.

Requests with errors are logged using logrus.Error(). Requests without errors are logged using logrus.Info().

It receives:

  1. A time package format string (e.g. time.RFC3339).
  2. A boolean stating whether to use UTC time zone or local.

func New

func New(cfg Config) *service

Types

type Config

type Config struct {
	HTTPServerConfig net.HTTPServerConfig

	// Set gin mode to release.
	ReleaseMode bool

	Storage storage.Storage

	// If specified, the server will use this function for determining time.
	Now func() time.Time
}

type HTTPErrorResponse

type HTTPErrorResponse struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (*HTTPErrorResponse) Error

func (er *HTTPErrorResponse) Error() string

type Server

type Server interface {
	Run() error
	Shutdown()
}

Jump to

Keyboard shortcuts

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