api

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 10 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	WholeSite     = "The whole website"
	ASpecificPage = "A specific page"
)

Variables

This section is empty.

Functions

func GenerateFeedbackMessage

func GenerateFeedbackMessage(f *models.Feedback, from, to string) []byte

func Unmarshal

func Unmarshal(body io.ReadCloser, v interface{}) error

unmarshal is an aux function to read the provided ReadCloser and unmarshal it to the provided model struct

Types

type API

type API struct {
	Cfg         *config.Config
	Router      chi.Router
	EmailSender EmailSender
}

API provides a struct to wrap the api around

func Setup

func Setup(ctx context.Context, cfg *config.Config, r chi.Router, e EmailSender) *API

Setup function sets up the api and returns an api

func (*API) PostFeedback

func (api *API) PostFeedback(w http.ResponseWriter, r *http.Request)

PostFeedback is the handler for POST /feedback It unmarshals and validates the feedback data before sending to configured email account

type EmailSender

type EmailSender interface {
	Send(from string, to []string, msg []byte) error
}

EmailSender defines the required methods from the email sender package

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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