support

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2020 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyBundle = errors.New("empty bundle")
)
View Source
var (
	Pool *x509.CertPool
)

Functions

func AcceptLanguageOfRequest

func AcceptLanguageOfRequest(req *http.Request) string

func ChannelDoOnEvent

func ChannelDoOnEvent(of Channel, what func())

func CreateDummyCertificate

func CreateDummyCertificate() (tls.Certificate, error)

func CreatePrivateKey

func CreatePrivateKey() (interface{}, error)

func Executable

func Executable() string

Executable returns the actual name of the executable

func FlagEnvName

func FlagEnvName(appPrefix, name string) string

func FlagEnvNameNormalize

func FlagEnvNameNormalize(what string) string

func HostOfRequest

func HostOfRequest(req *http.Request) string

func Join

func Join(sep string, what ...interface{}) string

func LoadBundle

func LoadBundle(provider FileProvider) (bundle *i18n.Bundle, err error)

func LogForRequest

func LogForRequest(req *http.Request) log.FieldLogger

func Must

func Must(err error)

func MustRegisterGlobalFalgs

func MustRegisterGlobalFalgs(fe FlagEnabled, appPrefix string)

func NegotiateContentType

func NegotiateContentType(requestedAccept string, offers []string) string

func NegotiateContentTypeOf

func NegotiateContentTypeOf(req *http.Request, offers ...string) string

func NormalizeHeaderContent

func NormalizeHeaderContent(val string) string

func PathAndQueryOfUri

func PathAndQueryOfUri(uri string) (path, query string, err error)

func PathOfRequest

func PathOfRequest(req *http.Request) string

func PathOfUri

func PathOfUri(uri string) (string, error)

func PublicKeyOf

func PublicKeyOf(candidate interface{}) interface{}

func QuoteAllIfNeeded

func QuoteAllIfNeeded(in ...string) []string

func QuoteAndJoin

func QuoteAndJoin(in ...string) string

func QuoteIfNeeded

func QuoteIfNeeded(what string) string

func RegisterGlobalFlags

func RegisterGlobalFlags(fe FlagEnabled, appPrefix string) error

func RemoteIpOfRequest

func RemoteIpOfRequest(req *http.Request) string

func RequestBasedLazyStringerFor

func RequestBasedLazyStringerFor(req *http.Request, delegate func(*http.Request) string) fmt.Stringer

func RequestIdOfRequest

func RequestIdOfRequest(req *http.Request) string

func SplitExt

func SplitExt(in string) (path, ext string)

func StdLog

func StdLog(fields log.Fields, lvl log.Level) *stdlog.Logger

func ToChan

func ToChan(channel Channel) chan struct{}

func ToLazyStringer

func ToLazyStringer(in StringerFunc) fmt.Stringer

func UriOfRequest

func UriOfRequest(req *http.Request) string

func UserAgentOfRequest

func UserAgentOfRequest(req *http.Request) string

Types

type AcceptRange

type AcceptRange struct {
	// Type represents the media type.
	Type string
	// Subtype represents the media subtype.
	Subtype string
	// Weight represents the weight (quality factor) of this range.
	Weight float64
	// Parameters represents the parameters that are applicable to this range.
	Parameters map[string]string
	// contains filtered or unexported fields
}

AcceptRange represents a media-range contained within an Accept header.

func ParseAcceptRange

func ParseAcceptRange(accept string) AcceptRange

ParseAcceptRange returns the media range, params and quality factor (weight) from an Accept range.

func ParseAcceptRanges

func ParseAcceptRanges(accepts string) []AcceptRange

ParseAcceptRanges returns the set of accepted media ranges from an Accept header.

func (AcceptRange) RawString

func (a AcceptRange) RawString() string

RawString returns the raw string for this accept range.

type Channel

type Channel interface {
	Wait()
	Broadcast()
}

func NewChannel

func NewChannel() Channel

type DefaultFileProviders

type DefaultFileProviders struct {
	Localization FileProvider
	Static       FileProvider
	Templates    FileProvider
}

func (DefaultFileProviders) GetLocalization

func (instance DefaultFileProviders) GetLocalization() FileProvider

func (DefaultFileProviders) GetStatic

func (instance DefaultFileProviders) GetStatic() FileProvider

func (DefaultFileProviders) GetTemplates

func (instance DefaultFileProviders) GetTemplates() FileProvider

type FileProvider

type FileProvider interface {
	List() []string
	Open(name string) (http.File, error)
	Find(filename string) ([]byte, error)
}

type FileProviders

type FileProviders interface {
	GetLocalization() FileProvider
	GetStatic() FileProvider
	GetTemplates() FileProvider
}

type FlagEnabled

type FlagEnabled interface {
	Flag(name, help string) *kingpin.FlagClause
}

type FlagRegistrar

type FlagRegistrar interface {
	RegisterFlag(fe FlagEnabled, appPrefix string) error
}

func RegisterFlagRegistrar

func RegisterFlagRegistrar(fr FlagRegistrar) FlagRegistrar

type GenericResponse

type GenericResponse struct {
	XMLName   xml.Name    `json:"-" yaml:"-" xml:"response"`
	Timestamp string      `json:"timestamp" yaml:"timestamp" xml:"timestamp"`
	Status    int         `json:"status" yaml:"status" xml:"status"`
	Message   string      `json:"message,omitempty" yaml:"message,omitempty" xml:"message,omitempty"`
	Path      string      `json:"path" yaml:"path" xml:"path"`
	RequestId string      `json:"requestId,omitempty" yaml:"requestId,omitempty" xml:"requestId,omitempty"`
	Data      interface{} `json:"data,omitempty" yaml:"data,omitempty" xml:"data,omitempty"`
}

func NewGenericResponse

func NewGenericResponse(statusCode int, message string, req *http.Request) GenericResponse

func (GenericResponse) StreamJsonTo

func (instance GenericResponse) StreamJsonTo(resp http.ResponseWriter, req *http.Request)

func (GenericResponse) StreamXmlTo

func (instance GenericResponse) StreamXmlTo(resp http.ResponseWriter, req *http.Request)

func (GenericResponse) StreamYamlTo

func (instance GenericResponse) StreamYamlTo(resp http.ResponseWriter, req *http.Request)

func (GenericResponse) WithData

func (instance GenericResponse) WithData(data interface{}) GenericResponse

func (GenericResponse) WithPath

func (instance GenericResponse) WithPath(path string) GenericResponse

func (GenericResponse) WithUri

func (instance GenericResponse) WithUri(uri string) (GenericResponse, error)

type LocalizationContext

type LocalizationContext struct {
	Bundle         *i18n.Bundle
	AcceptLanguage string
}

func (*LocalizationContext) LangBy

func (instance *LocalizationContext) LangBy(id string) language.Tag

func (*LocalizationContext) Message

func (instance *LocalizationContext) Message(id string) string

func (*LocalizationContext) MessageOrDefault

func (instance *LocalizationContext) MessageOrDefault(fallbackId string, id string) string

type LogWriter

type LogWriter struct {
	Fields log.Fields
	Level  log.Level
}

func (*LogWriter) Write

func (instance *LogWriter) Write(p []byte) (n int, err error)

type RuntimeT

type RuntimeT struct {
	GroupId    string    `yaml:"groupId" json:"groupId"`
	ArtifactId string    `yaml:"artifactId" json:"artifactId"`
	Revision   string    `yaml:"revision" json:"revision"`
	Branch     string    `yaml:"branch" json:"branch"`
	Build      time.Time `yaml:"build" json:"build"`
	GoVersion  string    `yaml:"goVersion" json:"goVersion"`
	Os         string    `yaml:"os" json:"os"`
	Arch       string    `yaml:"arch" json:"arch"`
}

RuntimeT hold the runtime information about this application. To provide the correct information to also enable the usage of:

Runtime()

...you have to call the build process with the correct parameters. We have build for that a small utility that escapes everything in the right order:

go run github.com/echocat/lingress/build \
	[-g <groupId>] \    # Default: ""
	-a <artifactId> \
	-b <branch> \
	-b <revision> \
	-o <output> \
	[<package>]         # Default ./

Example:

go run github.com/echocat/lingress/build \
	-g travel-the-pipe \
	-a some-backend \
	-b $BRANCH \
	-b $REVISION \
	-o out/app \
	./

func Runtime

func Runtime() RuntimeT

Runtime returns an instance of RuntimeT

func (RuntimeT) MarshalText

func (instance RuntimeT) MarshalText() (text []byte, err error)

func (RuntimeT) Name

func (instance RuntimeT) Name() string

func (RuntimeT) ShortString

func (instance RuntimeT) ShortString() string

func (RuntimeT) String

func (instance RuntimeT) String() string

type StringerFunc

type StringerFunc func() string

Jump to

Keyboard shortcuts

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