go fmt, add some basic tests for postal api info
This commit is contained in:
parent
f0799e0adb
commit
198fd10bf0
5 changed files with 21 additions and 4 deletions
3
main.go
3
main.go
|
@ -31,6 +31,9 @@ func main() {
|
||||||
users.TokenAuth = auth.TokenAuth
|
users.TokenAuth = auth.TokenAuth
|
||||||
blog.TokenAuth = auth.TokenAuth
|
blog.TokenAuth = auth.TokenAuth
|
||||||
|
|
||||||
|
// initilize auth
|
||||||
|
auth.Init()
|
||||||
|
|
||||||
// initiate the routes
|
// initiate the routes
|
||||||
router := Routes()
|
router := Routes()
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"github.com/go-chi/render"
|
"github.com/go-chi/render"
|
||||||
"golang.org/x/crypto/bcrypt"
|
"golang.org/x/crypto/bcrypt"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -20,8 +21,21 @@ import (
|
||||||
var (
|
var (
|
||||||
DB *sql.DB
|
DB *sql.DB
|
||||||
TokenAuth *jwtauth.JWTAuth
|
TokenAuth *jwtauth.JWTAuth
|
||||||
|
PostalEnabled bool
|
||||||
|
PostalKey string
|
||||||
|
PostalAPI string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func Init() {
|
||||||
|
if postal_key, ok := os.LookupEnv("POSTAL_KEY"); ok {
|
||||||
|
PostalKey = postal_key
|
||||||
|
if postal_api, ok := os.LookupEnv("POSTAL_API"); ok {
|
||||||
|
PostalAPI = postal_api
|
||||||
|
PostalEnabled = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type ReturnError struct {
|
type ReturnError struct {
|
||||||
Message string `json:"error"`
|
Message string `json:"error"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,6 @@ type ReferenceID struct {
|
||||||
LastID int `json:"last_id"`
|
LastID int `json:"last_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func Routes() *chi.Mux {
|
func Routes() *chi.Mux {
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
r.Group(func(r chi.Router) {
|
r.Group(func(r chi.Router) {
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
export DB_PW="CHANGEME"
|
export DB_PW="CHANGEME"
|
||||||
export POSTAL_API="POSTAL_API_KEY"
|
export POSTAL_KEY="POSTAL_API_KEY"
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
export API_PORT="8080"
|
export API_PORT="8080"
|
||||||
export JWT_SECRET="CHANGEMEALSO"
|
export JWT_SECRET="CHANGEMEALSO"
|
||||||
|
export POSTAL_API="https://POSTAL_URL"
|
||||||
|
|
Reference in a new issue