Go to file
jordi fita mas 4162da3a06 Force Content-Type to text/html when rendering a template
By chance, i found out that sometimes Go returned a Content-Type header
of text/plain for some responses to HTMx request.  Go’s documentation
for http.ResponseWriter.Write sheds some light to this issue:

> If the Header does not contain a Content-Type line, Write adds a
> Content-Type set to the result of passing the initial 512 bytes of
> written data to DetectContentType.

http.DetectContentType has “sniff signatures” for the most common HTML
elements, such as `<BODY`, `<P`, or even `<!--`, but when the template
only has elements not in that list, the text “text sniff signature”
kicks in because the content does not contain binary data bytes, as
specified in [0], §7.1, step 9.

I can not change mustRenderTemplate’s wr parameter, and its callers’,
to be of type http.ResponseWriter because mustWriteInvoicePdf writes
the template to a pipe object, which is not of this type.  Thus, i have
to resort to type assertion inside the method.

[0]: https://mimesniff.spec.whatwg.org/#identifying-a-resource-with-an-unknown-mime-type
2023-04-29 15:59:26 +02:00
cmd/numerus Implement login cookie, its verification, and logout 2023-01-17 20:58:13 +01:00
debian Convert invoices to PDF with WeasyPrint 2023-02-26 17:26:09 +01:00
demo Replace tag relations with array attributes 2023-04-07 21:31:35 +02:00
deploy Move the product_id field from invoice_product to a separate table 2023-04-19 19:30:12 +02:00
pkg Force Content-Type to text/html when rendering a template 2023-04-29 15:59:26 +02:00
po Add keyboard controls for product search 2023-04-28 00:06:48 +02:00
revert Move the product_id field from invoice_product to a separate table 2023-04-19 19:30:12 +02:00
test Move the product_id field from invoice_product to a separate table 2023-04-19 19:30:12 +02:00
verify Move the product_id field from invoice_product to a separate table 2023-04-19 19:30:12 +02:00
web Trigger a recompute when price, quantity, discount, or vat changes 2023-04-28 00:22:28 +02:00
.gitignore Ignore IntelliJ’s project files 2023-01-30 16:42:15 +01:00
COPYING Rename LICENSE to COPYING 2023-01-15 04:08:35 +01:00
Makefile Rename extension of templates to .gohtml 2023-01-30 16:48:21 +01:00
go.mod Properly register array and composite PostgreSQL types with pgtype 2023-02-20 11:42:21 +01:00
go.sum Fix use of API methods not available in Go 1.16 2023-02-13 10:32:26 +01:00
sqitch.conf Setup authentication schema and user relation 2023-01-13 20:30:21 +01:00
sqitch.plan Move the product_id field from invoice_product to a separate table 2023-04-19 19:30:12 +02:00