Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/umutsevdi/go-ssr-template
A template for a web server that features server side rendering and API capabilities using go's built-in html template engine.
https://github.com/umutsevdi/go-ssr-template
go go-html-template go-template golang html server template webserver
Last synced: 2 days ago
JSON representation
A template for a web server that features server side rendering and API capabilities using go's built-in html template engine.
- Host: GitHub
- URL: https://github.com/umutsevdi/go-ssr-template
- Owner: umutsevdi
- License: gpl-3.0
- Created: 2023-07-23T21:31:32.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-07-24T00:07:27.000Z (over 1 year ago)
- Last Synced: 2024-11-17T10:48:14.287Z (2 months ago)
- Topics: go, go-html-template, go-template, golang, html, server, template, webserver
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go Fullstack SSR Template
A template for a web server that features server side rendering and API capabilities
using go's built-in html template engine.## Features
- [x] Compile time page generation
- [x] Page indexing
- [x] Caching
- [x] Optional periodic cache updating
- [x] Runtime sitemap.xml generation
- [ ] Easier API routing.
- [ ] A cache mechanism to store pages with special variables. Currently
caching only stores pages that are compiled from components.## Project Structure
Project structure is displayed below. After compiling you can deploy your
application binary with `content` directory and `config.json`.```sh
.
├── app
│ ├── api
│ │ ├── router.go
│ │ └── /* Your API code goes here */
│ ├── go.mod
│ ├── go.sum
│ ├── main.go
│ ├── pages
│ │ ├── router.go
│ │ └── /* Your page rendering code goes here */
│ └── util
│ ├── config.go
│ └── index.go
├── config.json
├── content
│ ├── components
│ ├── pages
│ └── static
│ ├── css
│ ├── img
│ ├── js
│ ├── other
│ └── robots.txt /* Should be here */
└── Makefile
```
- **api**: Files in this directory are for responding requests from clients
after the page is loaded.
- **pages**: This directory is for inserting custom variables to the pages
such as personal data to render the final form of pages.
If a page is static or ready after initial compilation from the template engine
additional code is not required.
- **util**: This directory is for the library. Includes configuration files
parsing and caching.
- **config.json**: Configuration file for the server.## Configuration
Configuration is handled using `config.json` file that is under the same directory
with the binary.
```json
{
"url": "string", /* default: localhost */
"port": 80, /* default: 8080 */
"page": {
"enabled": true,
"ttl": -1
},
"memory": {
"enabled": true,
"ttl": -1
},
"content": "string" /* default: content */
}
```
- **url**: The URL of the page, will be used to generate `sitemap.xml`.
- **port**: Port(default:8080)
- **page**: How often pages generated from components should be refreshed.
Setting it to false will stop periodic indexing, and only generate once.
(default: {false, 0})
- **memory**: Whether specific final pages should be cached, if so how often
they should be cached. (default: {false, 0})`WARNING:` *This feature is not implemented yet.*
- **content**: Path to the content. If it's null, the program expects `content`
in the same directory.Content directory must be laid out like this:
```
└── content
├── components
├── pages
└── static
```# Building
```sh
make
```