servertools

package module
v0.0.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 4 Imported by: 1

README

Server Toolkit

Collections of tools to spinnup a Go server using exclusively the standard library.

Features

  1. Go template renderer
  2. Go template cache // Coming soon
  3. Logger middleware // Coming soon
tk := toolkit.Toolkit{
	TmplsDir:    "./ui/html/pages/", // Tmpl pages directory
	BaseTmplDir: "./ui/html/partials/layout.tmpl", // Tmpl base layout directory
}

// Call inside a HTTP handler
tk.RenderTmpl(w, r, "home.tmpl", http.StatusOK, data)

Instalation

go get github.com/raiesbo/server-toolkit@latest

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Tools

type Tools struct {
	TmplsDir    string
	BaseTmplDir string
}

func (*Tools) RenderTmpl

func (t *Tools) RenderTmpl(w http.ResponseWriter, r *http.Request, name string, code int, data any) error

RenderTmpl handles the rendering of templates including the main page template and the base layout

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL