parent
0e641df74b
commit
ad60ab7f93
|
@ -14,7 +14,7 @@ type auth0TokenResponse struct {
|
||||||
TokenType string
|
TokenType string
|
||||||
}
|
}
|
||||||
|
|
||||||
const tokenURL = "https://taxnexus.auth0.com/oauth/token"
|
const tokenURL = "https://taxnexus.auth0.com/oauth/token" //nolint:gosec // false positive
|
||||||
const tokenTimeout = 86400 * time.Second
|
const tokenTimeout = 86400 * time.Second
|
||||||
const requestTemplate = `
|
const requestTemplate = `
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,77 @@
|
||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// InjectResponseMeta takes a ResopnseMeta instance and injects additional metadata
|
||||||
|
func InjectResponseMeta(r *ResponseMeta) *ResponseMeta {
|
||||||
|
theResponseMeta := ResponseMeta{
|
||||||
|
Contact: "Contact Taxnexus at https://taxnexus.net/, info@taxnexus.net or +1-510-679-1900",
|
||||||
|
Copyright: "Taxnexus API and all Taxnexus content is Copyright (c) 2018-2020 by Taxnexus, Inc. All Rights Reserved.", //nolint:lll // response text
|
||||||
|
License: "Proprietary - Do Not Copy",
|
||||||
|
Pagination: r.Pagination,
|
||||||
|
TaxnexusAccount: r.TaxnexusAccount,
|
||||||
|
ServerInfo: r.ServerInfo,
|
||||||
|
ServerResponseTime: r.ServerResponseTime,
|
||||||
|
ServerTimestamp: r.ServerTimestamp,
|
||||||
|
RequestType: r.RequestType,
|
||||||
|
RequestIP: r.RequestIP,
|
||||||
|
RequestURL: r.RequestURL,
|
||||||
|
}
|
||||||
|
return &theResponseMeta
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewResponseMeta creates a template meta response
|
||||||
|
func NewResponseMeta() *ResponseMeta {
|
||||||
|
return &ResponseMeta{
|
||||||
|
Contact: "Contact Taxnexus at https://taxnexus.net/, info@taxnexus.net or +1-510-679-1900",
|
||||||
|
Copyright: "Taxnexus API and all Taxnexus content is Copyright (c) 2018-2020 by Taxnexus, Inc. All Rights Reserved.", //nolint:lll // response text
|
||||||
|
License: "Proprietary - Do Not Copy",
|
||||||
|
Pagination: &Pagination{
|
||||||
|
Limit: 1,
|
||||||
|
Pagesize: 1,
|
||||||
|
Poffset: 0,
|
||||||
|
Setsize: 1,
|
||||||
|
},
|
||||||
|
ServerInfo: "Taxnexus v1.2.7 - Go",
|
||||||
|
ServerTimestamp: fmt.Sprint(time.Now().Local()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewResponseMetaWithPagination creates a template meta response with pagination
|
||||||
|
func NewResponseMetaWithPagination(p *Pagination) *ResponseMeta {
|
||||||
|
return &ResponseMeta{
|
||||||
|
Contact: "Contact Taxnexus at https://taxnexus.net/, info@taxnexus.net or +1-510-679-1900",
|
||||||
|
Copyright: "Taxnexus API and all Taxnexus content is Copyright (c) 2018-2020 by Taxnexus, Inc. All Rights Reserved.", //nolint:lll // response text
|
||||||
|
License: "Proprietary - Do Not Copy",
|
||||||
|
ServerInfo: "Taxnexus v1.2.7 - Go",
|
||||||
|
ServerTimestamp: fmt.Sprint(time.Now()),
|
||||||
|
Pagination: p,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ResponseMeta is a struct
|
||||||
|
type ResponseMeta struct {
|
||||||
|
Contact string
|
||||||
|
Copyright string
|
||||||
|
License string
|
||||||
|
OperationID string
|
||||||
|
Pagination *Pagination
|
||||||
|
RequestIP string
|
||||||
|
RequestType string
|
||||||
|
RequestURL string
|
||||||
|
ServerInfo string
|
||||||
|
ServerResponseTime string
|
||||||
|
ServerTimestamp string
|
||||||
|
TaxnexusAccount string
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pagination is a struct
|
||||||
|
type Pagination struct {
|
||||||
|
Limit int64
|
||||||
|
Pagesize int64
|
||||||
|
Poffset int64
|
||||||
|
Setsize int64
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package app
|
||||||
|
|
||||||
|
import (
|
||||||
|
"database/sql"
|
||||||
|
)
|
||||||
|
|
||||||
|
// MyDB is the MySQL handler variable
|
||||||
|
var MyDB *sql.DB
|
||||||
|
|
||||||
|
// InitDB initializes the MySQL database using DSN information from the config file
|
||||||
|
func InitDB() {
|
||||||
|
var db *sql.DB
|
||||||
|
var err error
|
||||||
|
if GetDBMS() == "mysql" {
|
||||||
|
db, err = sql.Open("mysql", GetDSN())
|
||||||
|
} else {
|
||||||
|
sugar.Fatalf("app.InitDB: 💣 ⛔ unknown DBMS: %s", GetDBMS())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
sugar.Fatalf("app.InitDB: 💣 ⛔ Can't log on to DBMS host: %w", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
MyDB = db
|
||||||
|
sugar.Debugf("app.InitDB: 👍 📤 %s", GetDBMS())
|
||||||
|
}
|
Loading…
Reference in New Issue