Skip to content

Commit

Permalink
Fix gochecknoglobals
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilturek committed Aug 15, 2022
1 parent 49b8033 commit 377fd76
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions zpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ const PDF = "pdf"
const PNG = "png"
const ZPL = "zpl"

var allowedDensities = []int{6, 8, 12, 24}
var allowedOutputFormats = []string{PDF, PNG, ZPL}

var contentTypes = map[string]string{
PDF: "application/pdf",
PNG: "image/png",
}

type converter struct {
input io.Reader
density int // dpmm
Expand Down Expand Up @@ -90,6 +82,8 @@ func WithOutputPath(path string) option {
}

func WithOutputFormat(outputFormat string) option {
allowedOutputFormats := []string{PDF, PNG, ZPL}

return func(c *converter) error {
for _, allowedOutputFormat := range allowedOutputFormats {
if outputFormat == allowedOutputFormat {
Expand All @@ -104,6 +98,8 @@ func WithOutputFormat(outputFormat string) option {
}

func WithDensity(density int) option {
allowedDensities := []int{6, 8, 12, 24}

return func(c *converter) error {
for _, allowedDensity := range allowedDensities {
if density == allowedDensity {
Expand Down Expand Up @@ -178,6 +174,11 @@ func (c *converter) doRequest() (io.Reader, error) {
return nil, err
}

contentTypes := map[string]string{
PDF: "application/pdf",
PNG: "image/png",
}

req.Header.Set("Accept", contentTypes[c.outputFormat])

client := &http.Client{}
Expand Down

0 comments on commit 377fd76

Please sign in to comment.