globals

package
v0.0.0-...-7b4a482 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// below are not stored in context, and are used for ensuring tracing attributes are common.
	APPNAME_SAMPLEAPI   = "sampleApi"
	CLI_DEVICETYPE_NAME = "sampleCtl"
	OTEL_FILENAME       = "otel_sampleApi.txt"
)

Variables

View Source
var AuthConfig *openId.AuthCfg
View Source
var CorsWrapper = cors.New(cors.Options{
	AllowedMethods: []string{"GET", "POST"},
	AllowedHeaders: []string{"Content-Type", "Origin", "Accept", "*"},
})

For dev only - Set up CORS

Functions

func EncodeJSONResponse

func EncodeJSONResponse(ctx context.Context, i interface{}, status *int, w http.ResponseWriter) error

EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code

func GetAuthCfg

func GetAuthCfg() (*openId.AuthCfg, error)

func GetContextStringValue

func GetContextStringValue(ctx context.Context, key string) string

func GetRequestDetails

func GetRequestDetails(r *http.Request) (body string, params map[string]string, err error)

func HttpClientDo

func HttpClientDo(ctx context.Context, req *http.Request) (res *http.Response, err error)

Send http request without authorisation

func HttpClientDoWithAuthorisation

func HttpClientDoWithAuthorisation(ctx context.Context, req *http.Request, tokenType, accessToken string) (res *http.Response, err error)

Send http request with authorisation

func HttpLogger

func HttpLogger(ctx context.Context, inner http.Handler, name string) http.Handler

func LoadFile

func LoadFile(file string) (b []byte, err error)

func Logger

func Logger() *logger

func NewContext

func NewContext(timeout time.Duration) (ctx context.Context, cancelFunc context.CancelFunc, err error)

func NewFilesytem

func NewFilesytem(fstype FilesystemType) fileSystem

func SetAuthCfg

func SetAuthCfg(fname string) (err error)

func SetContextStringValue

func SetContextStringValue(ctx context.Context, key, value string) context.Context

Types

type ContextValueType

type ContextValueType string

type FilesystemType

type FilesystemType string
const (
	FILESYSTEM_LOCAL FilesystemType = "LocalFS"
)

Jump to

Keyboard shortcuts

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