Skip to content

Commit

Permalink
Resolved Template Preview Issue (communitybridge#3109)
Browse files Browse the repository at this point in the history
  • Loading branch information
dealako authored and nickmango committed Aug 16, 2021
1 parent b136b98 commit 9817c83
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 12 deletions.
19 changes: 17 additions & 2 deletions cla-backend-go/docraptor/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ func (dc Client) CreatePDF(html string, claType string) (io.ReadCloser, error) {
f := logrus.Fields{
"functionName": "v1.docraptor.client.CreatePDF",
"claType": claType,
"testMode": dc.testMode,
"url": dc.url,
}

document := map[string]interface{}{
Expand All @@ -69,9 +71,22 @@ func (dc Client) CreatePDF(html string, claType string) (io.ReadCloser, error) {
log.WithFields(f).Debug("Generating PDF using docraptor...")
resp, err := http.Post(dc.url, "application/json", bytes.NewBuffer(documentBytes))
if err != nil {
log.WithFields(f).WithError(err).Warn("problem with API call to docraptor")
log.WithFields(f).WithError(err).Warnf("problem with API call to docraptor url: %s", dc.url)
return nil, err
}
defer resp.Body.Close()
// Do not close - rely on the caller to close the reader otherwise we will get the read from Response.Body after Close error
//defer func() {
// closeErr := resp.Body.Close()
// if closeErr != nil {
// log.WithFields(f).WithError(closeErr).Warn("problem closing docraptor response")
// }
//}()
if resp.StatusCode < 200 || resp.StatusCode > 299 {
msg := fmt.Sprintf("unexpected http response code from docraptor url: %s, status code: %d", dc.url, resp.StatusCode)
log.WithFields(f).Warn(msg)
return nil, errors.New(msg)
}
log.WithFields(f).Debugf("successful response from docraptor url: %s, status code: %d", dc.url, resp.StatusCode)

return resp.Body, nil
}
26 changes: 25 additions & 1 deletion cla-backend-go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ require (
github.com/bitly/go-simplejson v0.5.0 // indirect
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869
github.com/bradleyfalzon/ghinstallation v1.1.1
github.com/coreos/bbolt v1.3.2 // indirect
github.com/coreos/etcd v3.3.13+incompatible // indirect
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e // indirect
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/davecgh/go-spew v1.1.1
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fnproject/fdk-go v0.0.2
github.com/gin-gonic/gin v1.7.2
github.com/go-delve/delve v1.7.0 // indirect
github.com/go-openapi/errors v0.19.6
github.com/go-openapi/loads v0.19.5
github.com/go-openapi/runtime v0.19.19
Expand All @@ -34,33 +40,50 @@ require (
github.com/google/go-github/v37 v37.0.0
github.com/google/uuid v1.1.4
github.com/gorilla/sessions v1.2.1 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/imroc/req v0.3.0
github.com/jessevdk/go-flags v1.4.0
github.com/jinzhu/copier v0.0.0-20190924061706-b57f9002281a
github.com/jmoiron/sqlx v1.2.0
github.com/jonboulle/clockwork v0.1.0 // indirect
github.com/juju/mempool v0.0.0-20160205104927-24974d6c264f // indirect
github.com/juju/zip v0.0.0-20160205105221-f6b1e93fa2e2
github.com/kr/pretty v0.2.0 // indirect
github.com/leodido/go-urn v1.2.1 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.13 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.4.1
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/mozillazg/request v0.8.0 // indirect
github.com/myitcv/gobin v0.0.14 // indirect
github.com/pdfcpu/pdfcpu v0.3.5-0.20200802160406-be1e0eb55afc
github.com/peterh/liner v1.2.1 // indirect
github.com/pkg/profile v0.0.0-20170413231811-06b906832ed0 // indirect
github.com/prometheus/client_golang v0.9.3 // indirect
github.com/rogpeppe/go-internal v1.8.0 // indirect
github.com/rs/cors v1.7.0
github.com/savaki/dynastore v0.0.0-20171109173440-28d8558bb429
github.com/shurcooL/githubv4 v0.0.0-20201206200315-234843c633fa
github.com/shurcooL/graphql v0.0.0-20200928012149-18c5c3165e3a // indirect
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.1.1
github.com/soheilhy/cmux v0.1.4 // indirect
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.8.1
github.com/stretchr/testify v1.7.0
github.com/tencentyun/scf-go-lib v0.0.0-20200116145541-9a6ea1bf75b8
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
github.com/ugorji/go v1.2.6 // indirect
github.com/verdverm/frisby v0.0.0-20170604211311-b16556248a9a
github.com/xanzy/go-gitlab v0.50.1
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
go.etcd.io/bbolt v1.3.2 // indirect
go.starlark.net v0.0.0-20210602144842-1cdb82c9e17a // indirect
go.uber.org/ratelimit v0.1.0
golang.org/x/arch v0.0.0-20210727222714-28578f966459 // indirect
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect
golang.org/x/image v0.0.0-20210628002857-a66eb6448b8d // indirect
golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985
Expand All @@ -69,4 +92,5 @@ require (
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/resty.v1 v1.12.0 // indirect
)
Loading

0 comments on commit 9817c83

Please sign in to comment.