add templating & dockerize application #2

Merged
jonasclaes merged 10 commits from dev/add-templating into main 2025-08-08 20:52:03 +00:00
jonasclaes commented 2025-08-08 20:42:00 +00:00 (Migrated from github.com)
No description provided.
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-08-08 20:42:46 +00:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull Request Overview

This PR adds templating functionality to the thermal printer application and containerizes it with Docker. The changes enable users to print receipts using template files with variable substitution instead of raw ESC/POS commands.

  • Adds a templating system with custom functions for formatting (bold, underline, italic)
  • Introduces a new /print-template API endpoint for template-based printing
  • Dockerizes the application with proper configuration for containerized deployment

Reviewed Changes

Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
templates/receipt.tmpl Sample receipt template demonstrating variable substitution and formatting functions
pkg/template/template.go Core templating engine with ESC/POS rendering functionality
pkg/service/printer-service.go Service layer method for template printing
pkg/service/print-service.go Low-level template rendering and printing methods
pkg/dto/printer-dto.go DTO for template printing requests
pkg/controller/printer-controller.go HTTP endpoint for template printing
Dockerfile Multi-stage Docker build with proper security practices
docker-compose.yml Docker Compose configuration for easy deployment
config.docker.toml Docker-specific configuration file
pkg/model/app-config.go Changed default host binding for container compatibility
pkg/escpos/const.go Extended character code page constants
## Pull Request Overview This PR adds templating functionality to the thermal printer application and containerizes it with Docker. The changes enable users to print receipts using template files with variable substitution instead of raw ESC/POS commands. - Adds a templating system with custom functions for formatting (bold, underline, italic) - Introduces a new `/print-template` API endpoint for template-based printing - Dockerizes the application with proper configuration for containerized deployment ### Reviewed Changes Copilot reviewed 16 out of 17 changed files in this pull request and generated 3 comments. <details> <summary>Show a summary per file</summary> | File | Description | | ---- | ----------- | | templates/receipt.tmpl | Sample receipt template demonstrating variable substitution and formatting functions | | pkg/template/template.go | Core templating engine with ESC/POS rendering functionality | | pkg/service/printer-service.go | Service layer method for template printing | | pkg/service/print-service.go | Low-level template rendering and printing methods | | pkg/dto/printer-dto.go | DTO for template printing requests | | pkg/controller/printer-controller.go | HTTP endpoint for template printing | | Dockerfile | Multi-stage Docker build with proper security practices | | docker-compose.yml | Docker Compose configuration for easy deployment | | config.docker.toml | Docker-specific configuration file | | pkg/model/app-config.go | Changed default host binding for container compatibility | | pkg/escpos/const.go | Extended character code page constants | </details>
@ -0,0 +50,4 @@
EXPOSE 8080
# Health check
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-08-08 20:42:46 +00:00

The health check uses 'wget' but the Alpine image doesn't include wget by default. Consider using 'curl' (which needs to be installed) or a simple approach like 'nc' for port checking, or install wget in the RUN command above.

The health check uses 'wget' but the Alpine image doesn't include wget by default. Consider using 'curl' (which needs to be installed) or a simple approach like 'nc' for port checking, or install wget in the RUN command above.
@ -0,0 +56,4 @@
},
"italics": func(text string) string {
return fmt.Sprintf("\x1B\x34\x01%s\x1B\x34\x00", text)
},
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-08-08 20:42:45 +00:00

The 'italics' function duplicates the exact same logic as the 'italic' function. Consider removing this duplicate or making one an alias of the other to reduce code duplication.

		"italic":   italicFunc,
		"italics":  italicFunc,
The 'italics' function duplicates the exact same logic as the 'italic' function. Consider removing this duplicate or making one an alias of the other to reduce code duplication. ```suggestion "italic": italicFunc, "italics": italicFunc, ```
@ -0,0 +10,4 @@
{{bold (printf "Subtotal: \xD5%.2f" .subtotal)}}
{{bold (printf "Tax: \xD5%.2f" .tax)}}
{{bold (printf "Total: \xD5%.2f" .total)}}
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-08-08 20:42:46 +00:00

The currency symbol '\xD5' is a magic number. Consider making this configurable or using a named constant to improve maintainability and support multiple currencies.

{{range $item, $price := .items}}{{$item}}: {{bold (printf "%s%.2f\n" .currencySymbol $price)}}{{end}}

{{bold (printf "Subtotal: %s%.2f" .currencySymbol .subtotal)}}
{{bold (printf "Tax:      %s%.2f" .currencySymbol .tax)}}
{{bold (printf "Total:    %s%.2f" .currencySymbol .total)}}
The currency symbol '\xD5' is a magic number. Consider making this configurable or using a named constant to improve maintainability and support multiple currencies. ```suggestion {{range $item, $price := .items}}{{$item}}: {{bold (printf "%s%.2f\n" .currencySymbol $price)}}{{end}} {{bold (printf "Subtotal: %s%.2f" .currencySymbol .subtotal)}} {{bold (printf "Tax: %s%.2f" .currencySymbol .tax)}} {{bold (printf "Total: %s%.2f" .currencySymbol .total)}} ```
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
jonasclaes/go-thermal-printer!2
No description provided.