server

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddRecord

func AddRecord(w http.ResponseWriter, r *http.Request) error

AddRecord is a handler that creates a record

func GetRecord

func GetRecord(w http.ResponseWriter, r *http.Request) error

getRecord is a handler that retrieves a record

func NewHTTPError

func NewHTTPError(err error, status int, detail string) error

func Serve

func Serve()

func Serverless added in v0.0.5

func Serverless(c Client) *mux.Router

func SetClient added in v0.0.5

func SetClient() error

Types

type BoltDB

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

func (*BoltDB) Close

func (b *BoltDB) Close()

func (*BoltDB) Connect

func (b *BoltDB) Connect() error

func (*BoltDB) Delete

func (b *BoltDB) Delete(r *Record) error

DeleteRecord deletes a bucket based on the r.Bucket value.

func (*BoltDB) Read

func (b *BoltDB) Read(r *Record) error

Read is just a wrapper to check the number of views left on a record. If the value is 0, then DeleteRecord is called.

func (*BoltDB) Write

func (b *BoltDB) Write(r *Record) error

BuildRecord does the initial record creation by generating a password, a bucket ID, encrypting the text, and then storing that data in the record.

type Client

type Client interface {
	Connect() error
	Write(*Record) error
	Read(*Record) error
	Delete(*Record) error
	Close()
}

type ClientError

type ClientError interface {
	Error() string
	Body() ([]byte, error)
	Headers() (int, map[string]string)
}

type ErrHandler

type ErrHandler func(http.ResponseWriter, *http.Request) error

func (ErrHandler) ServeHTTP

func (fn ErrHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Fauna

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

func (*Fauna) Close

func (f *Fauna) Close()

Close exists to satisfy the client interface

func (*Fauna) Connect

func (f *Fauna) Connect() error

func (*Fauna) Delete

func (f *Fauna) Delete(r *Record) error

Delete deletes a document from a collection in FaunaDB based on the ID from the Record.

func (*Fauna) Read

func (f *Fauna) Read(r *Record) error

Read is just a wrapper to be able to check the number of views left on the record. If the value is 0 it calls Delete.

func (*Fauna) Write

func (f *Fauna) Write(r *Record) error

BuildRecord does the initial record creation by generating a password and encrypting the text and then storing that in the record.

type HTTPError

type HTTPError struct {
	Cause   error  `json:"-"`
	Details string `json:"details"`
	Status  int    `json:"-"`
}

func (*HTTPError) Body

func (e *HTTPError) Body() ([]byte, error)

func (*HTTPError) Error

func (e *HTTPError) Error() string

func (*HTTPError) Headers

func (e *HTTPError) Headers() (int, map[string]string)

type Record

type Record struct {
	ID       string `json:"id,omitempty" fauna:"id"`
	Text     string `json:"text" fauna:"text"`
	Time     string
	Views    int    `json:"views" fauna:"views"`
	Password string `json:"password,omitempty" fauna:"password"`
	// contains filtered or unexported fields
}

func (*Record) Unmarshal

func (r *Record) Unmarshal(b io.Reader) error

Jump to

Keyboard shortcuts

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