From d35cf1d8a6be77fb7b314085b10bf1fd93434d10 Mon Sep 17 00:00:00 2001 From: mikestefanello Date: Wed, 29 Dec 2021 21:23:19 -0500 Subject: [PATCH] Updated README. --- README.md | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 62 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index aeb8957..9238324 100644 --- a/README.md +++ b/README.md @@ -751,7 +751,7 @@ While there are several methods available, the following is the primary one used Using the example from the [page rendering](#rendering-the-page), this is what the `Controller` will execute: ```go -buf, err = c.Container.TemplateRenderer.ParseAndExecute( +buf, err = c.TemplateRenderer.ParseAndExecute( "page", page.Name, page.Layout, @@ -814,22 +814,80 @@ While it's ideal to use cache control headers on your static files so browsers c For example, to render a file located in `static/picture.png`, you would use: ```go - + ``` Which would result in: ```go - + ``` Where `9fhe73kaf3` is the randomly-generated cache-buster. ## Email +An email client was added as a _Service_ to the `Container` but it is just a skeleton without any actual email-sending functionality. The reason is because there are a lot of ways to send email and most prefer using a SaaS solution for that. That makes it difficult to provide a generic solution that will work for most applications. + +Two starter methods were added to the `MailClient`, one to send an email via plain-text and one to send via a template by leveraging the [template renderer](#template-renderer). The standard library can be used if you wish to send email via SMTP and most SaaS providers have a Go package that can be used if you choose to go that direction. + ## HTTPS +By default, the application will not use HTTPS but it can be enabled easily. Just alter the following configuration: + +- `Config.HTTP.TLS.Enabled`: `true` +- `Config.HTTP.TLS.Certificate`: Full path to the certificate file +- `Config.HTTP.TLS.Key`: Full path to the key file + +To use _Let's Encrypt_ follow [this guide](https://echo.labstack.com/cookbook/auto-tls/#server). + ## Logging +Logging is provided by [Echo](https://echo.labstack.com/guide/customization/#logging) and is accessible within the _Echo_ instance, which is located in the `Web` field of the `Container`, or within any of the _context_ parameters, for example: + +```go +func (c *Home) Get(ctx echo.Context) error { + ctx.Logger().Info("something happened") + + if err := someOperation(); err != nil { + ctx.Logger().Errorf("the operation failed: %v", err) + } +} +``` + +The logger can be swapped out for another, as long as it implements Echo's logging [interface](https://github.com/labstack/echo/blob/master/log.go). There are projects that provide this bridge for popular logging packages such as [zerolog](https://github.com/rs/zerolog). + +### Request ID + +By default, Echo's [request ID middleware](https://echo.labstack.com/middleware/request-id/) is enabled on the router but it only adds a request ID to the log entry for the HTTP request itself. Log entries that are created during the course of that request do not contain the request ID. `LogRequestID()` is custom middleware included which adds that request ID to all logs created throughout the request. + ## Roadmap -## Credits \ No newline at end of file +Future work includes but is not limited to: + +- Email verification +- Flexible pager templates +- Expanded HTMX examples +- Admin section + +## Credits + +Thank you to all of the following amazing projects for making this possible. + +- [go](https://go.dev/) +- [echo](https://github.com/labstack/echo) +- [ent](https://github.com/ent/ent) +- [sprig](https://github.com/Masterminds/sprig) +- [goquery](https://github.com/PuerkitoBio/goquery) +- [validator](https://github.com/go-playground/validator) +- [go-redis](https://github.com/go-redis/redis) +- [gocache](https://github.com/eko/gocache) +- [sessions](https://github.com/gorilla/sessions) +- [pgx](https://github.com/jackc/pgx) +- [envdecode](https://github.com/joeshaw/envdecode) +- [testify](https://github.com/stretchr/testify) +- [htmx](https://github.com/bigskysoftware/htmx) +- [alpinejs](https://github.com/alpinejs/alpine) +- [bulma](https://github.com/jgthms/bulma) +- [docker](https://www.docker.com/) +- [postgresql](https://www.postgresql.org/) +- [redis](https://redis.io/) \ No newline at end of file