controllers

package
v0.0.0-...-b631e0d Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2018 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

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

Controller passes state to our handlers

func New

func New(storage Storage) *Controller

New is a Controller 'constructor'

func (*Controller) GetValue

func (c *Controller) GetValue(UseDefault bool) http.HandlerFunc

GetValue is a closure that wraps a HandlerFunc, if UseDefault is true value will always be "default" else it'll be whatever is stored in storage

func (*Controller) SetValue

func (c *Controller) SetValue(w http.ResponseWriter, r *http.Request)

SetValue modifies the underlying storage of the controller object

type MemStorage

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

MemStorage implements Storage

func (*MemStorage) Get

func (m *MemStorage) Get() string

Get our in-memory value

func (*MemStorage) Put

func (m *MemStorage) Put(s string)

Put our in-memory value

type Payload

type Payload struct {
	Value string `json:"value"`
}

Payload is our common response

type Storage

type Storage interface {
	Get() string
	Put(string)
}

Storage Interface Supports Get and Put of a single value

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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