comments

package
v0.0.0-...-af9d6d6 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2022 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalJSON

func MarshalJSON(c Comment) ([]byte, error)

Types

type Comment

type Comment struct {
	Name, Text string
	IP         string
	Date       time.Time
	Spam       bool
}

func UnmarshalJSON

func UnmarshalJSON(b []byte) (Comment, error)

type Service

type Service struct {
	Storage  Storage
	Password string
}

func Default

func Default() *Service

func WithStorage

func WithStorage(storage Storage) *Service

func (*Service) Comment

func (cs *Service) Comment(post string, c Comment) error

func (*Service) Load

func (cs *Service) Load(post string) ([]Comment, error)

func (*Service) ServeComments

func (cs *Service) ServeComments(post string, w http.ResponseWriter, r *http.Request) error

func (*Service) User

func (cs *Service) User(r *http.Request) (string, bool)

func (*Service) WriteHTML

func (cs *Service) WriteHTML(post string, w io.Writer) (int64, error)

func (*Service) WriteJSON

func (cs *Service) WriteJSON(post string, w io.Writer) (int64, error)

type Storage

type Storage interface {
	Store(post string, c Comment) error
	Retreive(post string) ([]Comment, error)
	ReadAll(post string) (io.Reader, error)
}

func NewDiskv

func NewDiskv(path string) Storage

Jump to

Keyboard shortcuts

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