Documentation ¶
Index ¶
- Constants
- Variables
- func GetBoolFromEnv(key string, defaultValue bool) bool
- func GetCORSWhitelist() []string
- func GetStringFromEnv(key string, defaultValue string) string
- func HTTPApp(config *AppConfig, customFlags []cli.Flag, commands ...*cli.Command) *cli.App
- func InitTracer(service string) (opentracing.Tracer, io.Closer, error)
- func IsUUID(s string) bool
- func LogDebugf(format string, v ...interface{})
- func LogErrorf(format string, v ...interface{})
- func LogFatalf(format string, v ...interface{})
- func LogInfof(format string, v ...interface{})
- func LogPrintf(format string, v ...interface{})
- func LogWarnf(format string, v ...interface{})
- func MergeFlags(flagGroups ...[]cli.Flag) []cli.Flag
- func NewHeader(description string) restful.Header
- func RouteAuthHeader(ws *restful.WebService) func(*restful.RouteBuilder)
- func RouteParams(params ...*restful.Parameter) func(*restful.RouteBuilder)
- func RouteReads(sample interface{}, description ...string) func(*restful.RouteBuilder)
- func RouteReturns(sample interface{}, responseCodes ...int) func(*restful.RouteBuilder)
- func RouteWrites(sample interface{}) func(*restful.RouteBuilder)
- func ServeCommand(config *AppConfig, customFlags []cli.Flag, commands ...*cli.Command) *cli.Command
- func ServeJSON(rw http.ResponseWriter, httpStatus int, data interface{}) error
- func StartSpan(context context.Context, variables ...string) (opentracing.Span, context.Context)
- func TimeUUID() string
- type AppConfig
- type Environment
- type LogOption
- type Logger
Constants ¶
View Source
const APIInsightsTraceID = "api_insights_trace_id"
View Source
const (
EnvCorsWhiteListFilePath = "CORS_WHITELIST_FILEPATH"
)
Variables ¶
View Source
var (
CorsHandlerEnabled = GetBoolFromEnv("SHARED_CORS_ENABLED", false)
)
View Source
var LogOpt = LogOption{LogFormat: "json", LogLevel: "info", LogName: ""}
LogOpt is global logging configuration instance
View Source
var ( // UUIDRegex describes the form of a valid UUID UUIDRegex = regexp.MustCompile("(?i)[0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12}") )
Functions ¶
func GetBoolFromEnv ¶
func GetCORSWhitelist ¶
func GetCORSWhitelist() []string
func GetStringFromEnv ¶
func HTTPApp ¶
func HTTPApp(config *AppConfig, customFlags []cli.Flag, commands ...*cli.Command) *cli.App
func InitTracer ¶
InitTracer returns an instance of Jaeger Tracer that samples 100% of traces and logs all spans to stdout.
func LogDebugf ¶
func LogDebugf(format string, v ...interface{})
LogDebugf logs message in debug level
func LogErrorf ¶
func LogErrorf(format string, v ...interface{})
LogErrorf logs message in error level
func LogFatalf ¶
func LogFatalf(format string, v ...interface{})
LogFatalf logs message in fatal level
func LogPrintf ¶
func LogPrintf(format string, v ...interface{})
LogPrintf logs message in error level
func MergeFlags ¶
func MergeFlags(flagGroups ...[]cli.Flag) []cli.Flag
func RouteAuthHeader ¶
func RouteAuthHeader(ws *restful.WebService) func(*restful.RouteBuilder)
func RouteParams ¶
func RouteParams(params ...*restful.Parameter) func(*restful.RouteBuilder)
func RouteReads ¶
func RouteReads(sample interface{}, description ...string) func(*restful.RouteBuilder)
func RouteReturns ¶
func RouteReturns(sample interface{}, responseCodes ...int) func(*restful.RouteBuilder)
func RouteWrites ¶
func RouteWrites(sample interface{}) func(*restful.RouteBuilder)
func ServeCommand ¶
func ServeCommand(config *AppConfig, customFlags []cli.Flag, commands ...*cli.Command) *cli.Command
Types ¶
type AppConfig ¶
type AppConfig struct { // AppVersion is the version of the microservice. AppVersion string `json:"appVersion"` // AppName is the name of the microservice. AppName string `json:"appName"` // AppPort the port for the App microservice web server to listen on. AppPort int `json:"appPort"` // AppHost is the host name for the App microservice. This is used // for the OAuth callback url. AppHost string `json:"appHost"` // AppEnvironment signals the environment this config is intended // to be. Possible values include 'production', 'development', etc. AppEnvironment Environment `json:"appEnvironment"` // ConfigDir is the directory to search for configuration JSON files. Defaults to working directory ConfigDir string `json:"configDir"` // HTTPHandler is the func that registers the microservice and // returns the restful.Container. HTTPHandler func(*AppConfig) (*restful.Container, error) `json:"-"` }
func (*AppConfig) LoadConfigFile ¶
func (*AppConfig) LoadConfigJSON ¶
type Environment ¶
type Environment string
const ( EnvTest Environment = "test" EnvDevelopment Environment = "development" EnvIntegration Environment = "integration" EnvStaging Environment = "staging" EnvProduction Environment = "production" )
type LogOption ¶
type LogOption struct { LogFormat string `long:"log-format" description:"Log Format - text or json" default:"json" env:"LOG_FORMAT"` LogLevel string `long:"log-level" description:"Log Level - debug, info, warn, error, or fatal" default:"info" env:"LOG_LEVEL"` LogName string `long:"log-name" description:"Log Name - log name" env:"LOG_NAME"` }
LogOption defines the cli options for service
type Logger ¶
type Logger interface { Debugf(format string, args ...interface{}) Errorf(format string, args ...interface{}) Fatalf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warnf(format string, args ...interface{}) Printf(format string, args ...interface{}) Print(v ...interface{}) Println(v ...interface{}) WithField(key string, value interface{}) Logger SetLevel(level string) error GetLevel() log.Level }
Logger defines a generic logging interface
func LoggerFromContext ¶
LoggerFromContext will return a Logger instance from context object
func LoggerFromRequest ¶
LoggerFromRequest will return a Logger instance from request object
Source Files ¶
Click to show internal directories.
Click to hide internal directories.