api

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

api.go: Queries db, exposes JSON API: 1. GET /monkeys.json: lists all entries 2. POST /monkeys.json: create entity of the type 3. GET /monkeys/[enc id].json retrieves a specific entity 4. PUT /monkeys/[enc id].json updates a specific entity 5. DELETE /monkey/[enc id].json: deletes that entity

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve()

Serve blocks forever, serving the API on bindAddr.

Types

type Monkey

type Monkey struct {
	Id        int       `json:"id"`
	Name      string    `json:"name"`
	Birthdate time.Time `json:"birthdate"`
}

Monkey is an entity we deal with in the API.

func (Monkey) String

func (m Monkey) String() string

String returns a human-readable description of the monkey.

type MonkeyAPI

type MonkeyAPI interface {
	GetMonkey(int) (*Monkey, error)
	GetMonkeys() (*Monkeys, error)
	AddMonkey(Monkey) error
}

MonkeyAPI defines the interface on how we interact with monkeys.

type Monkeys

type Monkeys []*Monkey

Monkeys are a collection of monkey.

func (Monkeys) String

func (ms Monkeys) String() string

String returns a human-readable description of the monkeys.

Directories

Path Synopsis
cmd
apiserver
apiserver is a simple binary that runs the API server
apiserver is a simple binary that runs the API server

Jump to

Keyboard shortcuts

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