formatting

package
v0.0.0-...-f97d723 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TemplateData

type TemplateData struct {
	// contains filtered or unexported fields
}

func NewTemplateData

func NewTemplateData(tmplString string) *TemplateData

NewTemplateData returns a new TemplateData instance. It takes the template string as a parameter. The template string is the string that will be used to render the template. The data is the map of data that will be used to render the template.

func (*TemplateData) Render

func (d *TemplateData) Render() (string, error)

Render returns the rendered template string. It takes the template string from the TemplateData instance and the data stored in the TemplateData instance. It returns an error if the template string is invalid or when rendering the template fails.

func (*TemplateData) WithData

func (d *TemplateData) WithData(name string, data interface{}) *TemplateData

WithData adds a key-value pair to the data map. The key is the name of the variable and the value is the value of the variable.

func (*TemplateData) WithPayload

func (d *TemplateData) WithPayload(payload []byte) *TemplateData

WithPayload adds a payload to the data map. The key of payload is "Payload". The payload is basically the body of the request.

func (*TemplateData) WithRequest

func (d *TemplateData) WithRequest(r *http.Request) *TemplateData

WithRequest adds a http.Request object to the data map. The key of request is "Request".

Jump to

Keyboard shortcuts

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