http

package
v0.0.0-...-510a38a Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2022 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleInt64

func HandleInt64(key string, rw http.ResponseWriter, r *http.Request) int64

handle int64 path parameter

func HandleString

func HandleString(key string, r *http.Request) string

handle string path parameter

func NewHealth

func NewHealth(version, env string) *health

Types

type AuthorStore

type AuthorStore interface {
	Get(id int64) (*teal.Author, error)
	GetByName(name string) (*teal.Author, error)
	GetAll() ([]*teal.Author, error)
	Create(b *teal.Author) (*teal.Author, error)
	Update(id int64, b *teal.Author) (*teal.Author, error)
	Delete(id int64) error
}

type BookStore

type BookStore interface {
	Get(id int64) (*teal.Book, error)
	GetByISBN(isbn string) (*teal.Book, error)
	GetAll(filters teal.BookFilters) ([]*teal.Book, int, error)
	Create(b *teal.Book) (*teal.Book, error)
	Update(id int64, b *teal.Book) (*teal.Book, error)
	Delete(id int64) error
}

type Server

type Server struct {
	Server  *http.Server
	Router  *mux.Router
	InfoLog *log.Logger
	ErrLog  *log.Logger

	Books   BookStore
	Authors AuthorStore
	Users   UserStore
}

func NewServer

func NewServer() *Server

func (*Server) AddAuthor

func (s *Server) AddAuthor(rw http.ResponseWriter, r *http.Request)

func (*Server) AddBook

func (s *Server) AddBook(rw http.ResponseWriter, r *http.Request)

func (*Server) Close

func (s *Server) Close() error

func (*Server) DeleteAuthor

func (s *Server) DeleteAuthor(rw http.ResponseWriter, r *http.Request)

func (*Server) DeleteBook

func (s *Server) DeleteBook(rw http.ResponseWriter, r *http.Request)

func (*Server) DeleteUser

func (s *Server) DeleteUser(rw http.ResponseWriter, r *http.Request)

func (*Server) GetAllAuthors

func (s *Server) GetAllAuthors(rw http.ResponseWriter, r *http.Request)

func (*Server) GetAllBooks

func (s *Server) GetAllBooks(rw http.ResponseWriter, r *http.Request)

func (*Server) GetAuthor

func (s *Server) GetAuthor(rw http.ResponseWriter, r *http.Request)

func (*Server) GetAuthorByName

func (s *Server) GetAuthorByName(rw http.ResponseWriter, r *http.Request)

func (*Server) GetBook

func (s *Server) GetBook(rw http.ResponseWriter, r *http.Request)

func (*Server) GetBookByISBN

func (s *Server) GetBookByISBN(rw http.ResponseWriter, r *http.Request)

func (*Server) GetUser

func (s *Server) GetUser(rw http.ResponseWriter, r *http.Request)

func (*Server) GetUserByUsername

func (s *Server) GetUserByUsername(rw http.ResponseWriter, r *http.Request)

func (*Server) Healthcheck

func (s *Server) Healthcheck(rw http.ResponseWriter, r *http.Request)

func (*Server) ImportMetadata

func (s *Server) ImportMetadata(rw http.ResponseWriter, r *http.Request)

POST {"isbn": [isbn]} to /api/books/:id/

func (*Server) Register

func (s *Server) Register(rw http.ResponseWriter, r *http.Request)

func (*Server) RegisterRoutes

func (s *Server) RegisterRoutes()

func (*Server) Run

func (s *Server) Run(port string) error

func (*Server) UpdateAuthor

func (s *Server) UpdateAuthor(rw http.ResponseWriter, r *http.Request)

func (*Server) UpdateBook

func (s *Server) UpdateBook(rw http.ResponseWriter, r *http.Request)

func (*Server) UpdateUser

func (s *Server) UpdateUser(rw http.ResponseWriter, r *http.Request)

type UserStore

type UserStore interface {
	Get(id int64) (*teal.User, error)
	GetByUsername(username string) (*teal.User, error)
	Create(u *teal.User) (*teal.User, error)
	Update(id int64, b *teal.User) (*teal.User, error)
	Delete(id int64) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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