コード例 #1
0
ファイル: store.go プロジェクト: andrebq/exp
			deliverycount int not null,
			senderid int not null,
			receiverid int not null
		)`,
		`do
		$$
		begin
			alter table pgstore_messages
				add constraint pgstore_unq_messages_mid unique(mid);
		exception when duplicate_table then
		end
		$$ language plpgsql;`,
		`create table if not exists pgstore_messageboxes (id integer not null default nextval('pgstore_seq_messages'), name text not null)`,
	}

	ErrKeyNotFound = pandora.ApiError("key not found")
)

type memoryBuffer interface {
	Bytes() []byte
}

// MessageStore implements pandora.MessageStore using postgresql as backend
type MessageStore struct {
	sync.RWMutex
	conn *sql.DB
	bs   *BlobStore
}

// OpenMessageStore opens the message store with the given parameters
func OpenMessageStore(user, pwd, host, dbname string) (*MessageStore, error) {
コード例 #2
0
ファイル: api.go プロジェクト: andrebq/exp
	"github.com/andrebq/exp/pandora"
	"io"
	"log"
	"net/http"
	"net/url"
	"strconv"
	"strings"
	"time"
)

type jsonOutput struct {
	val interface{}
}

const (
	ErrNotFound     = pandora.ApiError("not found")
	ErrPOSTRequired = pandora.ApiError("POST is required")
)

var (
	ErrServerPanic = errors.New("bad behavior from the server....")
)

// Handler is the base type used to process
// http request to a pandora server
type Handler struct {
	Server     *pandora.Server
	AllowAdmin bool
}

func (ph *Handler) respondWith(w http.ResponseWriter, req *http.Request, val interface{}) {