monster

package module
v0.0.0-...-648ece1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2019 License: MIT Imports: 6 Imported by: 0

README

Monster API

The Monster API, is a simple CRUD API for development purpose, this API can be used to create a demo projects, katas, etc...

The API request/response is based on JSON:API specification.

How can I use it?

Install
$ go get -u github.com/aperezg/monster/cmd/monster
Usage

Launch server with predefined data

$ monster --withData

Launch server with custom host and port

$ monster --port 8080 --host monster.io

Endpoints

Create a new monster

POST /monsters

Update a monster

PATCH /monsters/{monster_id}

Delete a monster

DELETE /monsters/{monster_id}

Fetch all monsters

GET /monsters

Fetch a monster by ID

GET /monsters/{monster_id}

Contributing

If you think that you can improve with new endpoints, and functionallities the API feel free to contribute with this project with fork this repo and send your Pull Request.

License

MIT License, see LICENSE

Documentation

Index

Constants

View Source
const (
	WaterType MonsterType = "water"
	FireType              = "fire"
	WindType              = "wind"
	EarthType             = "earth"
)

Variables

View Source
var Monsters = map[string]*Monster{
	"01D2HFC5XCDMVHP80ZH44JNHZ4": &Monster{
		ID:      "01D2HFC5XCDMVHP80ZH44JNHZ4",
		Name:    "Chupacabra",
		Attack:  150,
		Defense: 500,
		Type:    EarthType,
	},
	"01D2HV4AYW1YK6TGXE2YZ4DQGR": &Monster{
		ID:      "01D2HV4AYW1YK6TGXE2YZ4DQGR",
		Name:    "Nessie",
		Attack:  10,
		Defense: 999,
		Type:    WaterType,
	},
	"01D2HV56HKYM349958P5ZSM24Q": &Monster{
		ID:      "01D2HV56HKYM349958P5ZSM24Q",
		Name:    "Zombie",
		Attack:  300,
		Defense: 100,
		Type:    EarthType,
	},
	"01D2HV77H0XTA1C5AV317KTNRS": &Monster{
		ID:      "01D2HV77H0XTA1C5AV317KTNRS",
		Name:    "Kraken",
		Attack:  700,
		Defense: 400,
		Type:    WaterType,
	},
	"01D2HVBX3NTV5SB34YJH9K7KW9": &Monster{
		ID:      "01D2HVBX3NTV5SB34YJH9K7KW9",
		Name:    "Godzilla",
		Attack:  999,
		Defense: 800,
		Type:    EarthType,
	},
}

Functions

This section is empty.

Types

type Monster

type Monster struct {
	ID      string      `jsonapi:"primary,monsters"`
	Name    string      `jsonapi:"attr,name"`
	Attack  int         `jsonapi:"attr,attack"`
	Defense int         `jsonapi:"attr,defense"`
	Type    MonsterType `json:"type" jsonapi:"attr,type"`
}

func NewMonster

func NewMonster() *Monster

func (*Monster) Validate

func (m *Monster) Validate() error

type MonsterType

type MonsterType string

func (*MonsterType) Check

func (t *MonsterType) Check() error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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