application

package
v0.0.0-...-da2f3a4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

The "author" GET, POST and DELETE response functionality for requests to the /author endpoint. A part of the authors methods for the rest-api-go application. Governed by the license that can be found in the LICENSE file

The "authors" response functionality for requests to the /authors endpoint. A part of the authors methods for the rest-api-go application. Governed by the license that can be found in the LICENSE file

The "health" response functionality for requests to the /health endpoint. A part of the toolbox (utility) methods for the rest-api-go application. Governed by the license that can be found in the LICENSE file

The "quote" GET, POST and DALETE response functionality for requests to the /quote endpoint. A part of the quotes methods for the rest-api-go application. Governed by the license that can be found in the LICENSE file

The "quotes" response functionality for requests to the /quotes endpoint. A part of the quotes methods for the rest-api-go application. Governed by the license that can be found in the LICENSE file

The "ready" response functionality for requests to the /ready endpoint. A part of the toolbox (utility) methods for the rest-api-go application. Governed by the license that can be found in the LICENSE file

The "version" response functionality for requests to the /version endpoint. A part of the toolbox (utility) methods for the rest-api-go application. Governed by the license that can be found in the LICENSE file

Index

Constants

This section is empty.

Variables

View Source
var Authors []Author
View Source
var Authorsmin []AuthorMin
View Source
var Quotes []Quote
View Source
var Quotesmin []QuoteMin

Functions

func GetHealth

func GetHealth(w http.ResponseWriter, r *http.Request)

GetHealth looks up the health of the application. GET /health Returns all of the health status of all the components of the application.

func GetVersion

func GetVersion(w http.ResponseWriter, r *http.Request)

GetVersion looks up the current version of the application. GET /version Returns the current version of the application.

Types

type App

type App struct {
	Router *mux.Router
	DB     *gorm.DB
}

func (*App) CreateAuthor

func (a *App) CreateAuthor(w http.ResponseWriter, r *http.Request)

CreateAuthor creates a new author. POST /author Returns newly created author ID.

func (*App) CreateQuote

func (a *App) CreateQuote(w http.ResponseWriter, r *http.Request)

CreateQuote creates a new quote. Validates that the author ID exists. POST /quote Returns the ID of new quote as a part of the "status" response message.

func (*App) DeleteAuthor

func (a *App) DeleteAuthor(w http.ResponseWriter, r *http.Request)

Delete Author deletes an author by author ID. DELETE /author/{id} Returns a status message that includes the ID of the author record deleted.

func (*App) DeleteQuote

func (a *App) DeleteQuote(w http.ResponseWriter, r *http.Request)

DeleteQuote deletes a quote by quote ID. DELETE /quote/{id} Returns.

func (*App) GetAuthor

func (a *App) GetAuthor(w http.ResponseWriter, r *http.Request)

GetAuthor looks up a specific author by ID. GET /author Looks up a author in the database by ID and returns results JSON format.

func (*App) GetAuthors

func (a *App) GetAuthors(w http.ResponseWriter, r *http.Request)

GetAuthors looks up all of the authors. GET /authors Populates authors slice with all of the author records in the database and returns JSON formatted listing. @todo: exclude author information in quotes list with each author

func (*App) GetQuote

func (a *App) GetQuote(w http.ResponseWriter, r *http.Request)

GetQuote looks up a specific quote by ID. GET /quote/{id} Returns a quote in the JSON format provided the target ID is valid.

func (*App) GetQuotes

func (a *App) GetQuotes(w http.ResponseWriter, r *http.Request)

GetQuotes looks up all of the quotes. GET /quotes Returns all of the quotes in JSON format.

func (*App) GetReady

func (a *App) GetReady(w http.ResponseWriter, r *http.Request)

GetReady determines if the application is ready to process requests. GET /ready Returns the application state to determine if the application is ready to process requests.

func (*App) Initialize

func (a *App) Initialize(dbUser, dbPassword, dbName, dbHost string)

func (*App) Run

func (a *App) Run(dbPort int)

type Author

type Author struct {
	AuthorMin
	Quotes []QuoteMin `json:"quotes,omitempty"` // One-To-Many
}

Author type, referenced by core items: quotes, publications, etc.

type AuthorMin

type AuthorMin struct {
	// gorm.Model
	ID        uint `gorm:"primary;key";json:"id"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time

	First       string    `json:"first,omitempty"`
	Last        string    `json:"last,omitempty"`
	Born        time.Time `json:"born,omitempty"`
	Died        time.Time `json:"died,omitempty"`
	Description string    `json:"description,omitempty"`
	BioLink     string    `json:"biolink,omitempty"`
}

Author type, referenced by core items: quotes, publications, etc.

type Health

type Health struct {
	Refer      string `json:"reference,omitempty"`
	Alloc      uint64 `json:"alloc,omitempty"`
	TotalAlloc uint64 `json:"total-alloc,omitempty"`
	Sys        uint64 `json:"sys,omitempty"`
	NumGC      uint32 `json:"numgc,omitempty"`
}

type Quote

type Quote struct {
	QuoteMin
	Author AuthorMin `json:"author,omitempty"`
}

Quote type (more like an object), manages the details of a quote.

type QuoteMin

type QuoteMin struct {
	// gorm.Model
	ID        uint `gorm:"primary;key";json:"id"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time

	Quote    string `json:"quote"`
	AuthorID uint   `gorm:"index";json:"authorid"`
}

Quote type (more like an object), manages the details of a quote.

type Ready

type Ready struct {
	DbReady  string `json:"dbReady,omitempty"`
	AppReady string `json:"appReady,omitempty"`
}

type Version

type Version struct {
	Version     string `json:"version,omitempty"`
	ReleaseDate string `json:"release-date,omitempty"`
}

Jump to

Keyboard shortcuts

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