guestbook

package
v0.0.0-...-0355399 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2013 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package guestbook implements a simple Guest Book with in-memory data storage. This is mainly used to demonstrate how to convert a standard service type in a webservice.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GuestBook

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

GuestBook represents a Guest Book instance. It holds the associated GuestBookEntries.

func NewGuestBook

func NewGuestBook() *GuestBook

NewGuestBook returns a new empty GuestBook instance.

func (*GuestBook) AddEntry

func (g *GuestBook) AddEntry(email, title, content string) int

AddEntry adds a new GuestBookEntry with the provided data.

func (*GuestBook) GetAllEntries

func (g *GuestBook) GetAllEntries() []*GuestBookEntry

GetAllEntries returns all non-nil entries in the Guest Book.

func (*GuestBook) GetEntry

func (g *GuestBook) GetEntry(id int) (*GuestBookEntry, error)

GetEntry returns the entry identified by the given id or an error if it can not find it.

func (*GuestBook) GetPath

func (g *GuestBook) GetPath() string

GetPath implements webservice.GetPath.

func (*GuestBook) RemoveAllEntries

func (g *GuestBook) RemoveAllEntries()

RemoveAllEntries removes all entries from the Guest Book.

func (*GuestBook) RemoveEntry

func (g *GuestBook) RemoveEntry(id int) error

RemoveEntry removes the entry with the given id. Return nil in case of success or a specific error in case of failure.

func (*GuestBook) WebDelete

func (g *GuestBook) WebDelete(params martini.Params) (int, string)

WebDelete implements webservice.WebDelete.

func (*GuestBook) WebGet

func (g *GuestBook) WebGet(params martini.Params) (int, string)

WebGet implements webservice.WebGet.

func (*GuestBook) WebPost

func (g *GuestBook) WebPost(params martini.Params,
	req *http.Request) (int, string)

WebPost implements webservice.WebPost.

type GuestBookEntry

type GuestBookEntry struct {
	Id      int
	Email   string
	Title   string
	Content string
}

GuestBookEntry represents a single entry in a Guest Book. It contains the usual fields.

Jump to

Keyboard shortcuts

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