modulepackage
0.0.0-20210803095900-6e3dd02fb070
Repository: https://github.com/sflabsorg/sfutils.git
Documentation: pkg.go.dev
# README
SF labs utils
The main purpose of this repository is to collect code that can be reused in one or more applications in order to speed up their development.
Gin
Entry point for gin configuration is NewGin function.
Configuration can be done via next environment variables:
- GIN_MODE - debug/release/test
- GIN_TEMPLATES_MODE - debug/release (if the variable is not set, templates are not loaded)
- GIN_TEMPLATES_PATH - absolute/relative path to html templates
- ENABLE_PPROF - enable/disable golang profiler on path /system/pprof
- ENABLE_PROMETHEUS - enable/disable gin metrics for prometheus on path /system/prometheus
- ENABLE_OPENAPI - enable/disable openapi schema on path /system/openapi
Gin templates
A small object that makes it easier to work with html templates in gin. You can do without it if you don't need to render any html at all.
Gin OpenAPI
A small hack to add openapi specification file to /system/openapi.
How to use it:
- Set environment variable
ENABLE_OPENAPI=true
- Add the following lines to your project:
//go:embed api.yml
var openAPIData []byte
- Point sfutils to this variable:
sfutils.SetOpenAPIData(openAPIData)
Remark about go pprof with basic auth
go tool pprof 'user:[email protected]:8080/system/pprof/heap'
go tool pprof 'user:[email protected]:8080/system/pprof/profile?seconds=30'
# Packages
No description provided by the author
# Functions
CheckApplePay request the AppStore for complete product information.
CheckGooglePlay check if the service is available for payment and then get information about the product using his product_id.
GetOrCreateGooglePlayService return or create a new service for payment verification.
NewGin returns new gin.Engine object, ready to use.
No description provided by the author
NewMetric associates prometheus.Collector based on Metric.Type.
NewPrometheus generates a new set of metrics with a certain subsystem name.
No description provided by the author
RequestToPayPlatform parsing the answer and issuing an answer on a given platform.
No description provided by the author
# Variables
No description provided by the author
No description provided by the author
# Structs
No description provided by the author
IOSResponseData Apple's response structure.
Metric is a definition for the name, description, type, ID, and prometheus.Collector type (i.e.
Prometheus contains the metrics gathered by the instance and its path.
PrometheusPushGateway contains the configuration for pushing to a Prometheus pushgateway (optional).
No description provided by the author
# Type aliases
No description provided by the author
RequestCounterURLLabelMappingFn is a function which can be supplied to the middleware to control
the cardinality of the request counter's "url" label, which might be required in some contexts.