api

package
v0.0.0-...-3dda40d Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BookHandleFunc

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

BookHandleFunc to be used as http.HandleFunc for Book API

func BooksHandleFunc

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

BooksHandleFunc to be used as http.HandleFunc for Book API

func CreateBook

func CreateBook(book Book) (string, bool)

CreateBook creates a new Book if it does not exist

func DeleteBook

func DeleteBook(isbn string)

DeleteBook removes a book from the map by ISBN key

func EchoHandleFunc

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

EchoHandleFunc to be used as http.HandleFunc for ECHO API

func HelloHandleFunc

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

HelloHandleFunc to be used as http.HandleFunc for Hello API

func StartApi

func StartApi(string)

func UpdateBook

func UpdateBook(isbn string, book Book) bool

UpdateBook updates an existing book

func UserHandleFunc

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

Types

type Book

type Book struct {
	Title       string `json:"title"`
	Author      string `json:"author"`
	ISBN        string `json:"isbn"`
	Description string `json:"description,omitempty"`
}

Book type with Name, Author and ISBN

func AllBooks

func AllBooks() []*Book

AllBooks returns a slice of all books

func FromDB

func FromDB() []*Book

func FromJSON

func FromJSON(data []byte) Book

FromJSON to be used for unmarshalling of Book type

func GetBook

func GetBook(isbn string) (*Book, bool)

GetBook returns the book for a given ISBN

func (Book) ToJSON

func (b Book) ToJSON() []byte

ToJSON to be used for marshalling of Book type

type ErrResponse

type ErrResponse struct {
	Message string
}

type Hello

type Hello struct {
	Message string
}

Hello response structure

type Login

type Login struct {
	Username string
	Password string
}

type Response

type Response struct {
	Data []vulnerableDB.User
}

type User

type User struct {
	ID       int
	Username string
	Password string
	Email    string
}

Jump to

Keyboard shortcuts

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