api

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

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