numerus/pkg
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
..
company.go Create constants for the HTMX request and response headers used 2023-04-06 12:07:20 +02:00
contacts.go Move back most dialogs to regular (but still boosted) pages 2023-04-25 15:28:55 +02:00
db.go Properly register array and composite PostgreSQL types with pgtype 2023-02-20 11:42:21 +01:00
form.go Use HTMx to add product rows “inline” in the invoice form 2023-04-24 02:00:38 +02:00
htmx.go Use HTMx to add product rows “inline” in the invoice form 2023-04-24 02:00:38 +02:00
invoices.go Trigger a recompute when price, quantity, discount, or vat changes 2023-04-28 00:22:28 +02:00
locale.go Add currency_pattern to language relation 2023-02-23 12:12:33 +01:00
logger.go Move source file to the root of pkg 2023-01-17 10:40:22 +01:00
login.go Replace default router with github.com/julienschmidt/httprouter 2023-02-03 12:30:56 +01:00
pgtypes.go Accept “invalid” quantity, price, and discount on invoice update 2023-04-24 20:40:10 +02:00
products.go Move back most dialogs to regular (but still boosted) pages 2023-04-25 15:28:55 +02:00
profile.go Create constants for the HTMX request and response headers used 2023-04-06 12:07:20 +02:00
recover.go Gofmt recover.go 2023-01-22 20:37:34 +01:00
router.go Use HTMx to add product rows “inline” in the invoice form 2023-04-24 02:00:38 +02:00
template.go Force Content-Type to text/html when rendering a template 2023-04-29 15:59:26 +02:00