github.com/elliott5/community@v0.14.1-0.20160709191136-823126fb026a/documize/api/convert/apidocumizecom/init.go (about) 1 // Copyright 2016 Documize Inc. <legal@documize.com>. All rights reserved. 2 // 3 // This software (Documize Community Edition) is licensed under 4 // GNU AGPL v3 http://www.gnu.org/licenses/agpl-3.0.en.html 5 // 6 // You can operate outside the AGPL restrictions by purchasing 7 // Documize Enterprise Edition and obtaining a commercial license 8 // by contacting <sales@documize.com>. 9 // 10 // https://documize.com 11 12 package apidocumizecom 13 14 import ( 15 "crypto/tls" 16 "errors" 17 "net/http" 18 19 "github.com/documize/community/documize/api/request" 20 ) 21 22 func endPoint() string { 23 r := request.ConfigString("LICENSE", "endpoint") 24 if r != "" { 25 return r 26 } 27 return "https://api.documize.com" 28 } 29 30 func token() (string, error) { 31 r := request.ConfigString("LICENSE", "token") 32 if r == "" { 33 return "", errors.New("Documize token is empty") 34 } 35 // TODO more validation here 36 return r, nil 37 } 38 39 var transport = &http.Transport{ 40 TLSClientConfig: &tls.Config{ 41 InsecureSkipVerify: true, // TODO should be glick.InsecureSkipVerifyTLS (from -insecure flag) but get error: x509: certificate signed by unknown authority 42 }} 43 44 // CheckToken returns an error if the Documize LICENSE token is invalid. 45 func CheckToken() error { 46 _, err := token() 47 return err 48 }