api

package
v0.0.0-...-9197a6d Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// Router is the router to be used by the handlers.
	Router *mux.Router
	// DB is the database to be used by the handlers.
	DB *gorm.DB
	// Logger is the logger to be used by the handlers.
	Logger *support.Logger
}

Service represents the service with fields to be injected into the handlers.

func NewService

func NewService(r *mux.Router, db *gorm.DB, log *support.Logger) *Service

NewService returns a new service instance. It expects the service to be used in a HTTP server.

func (*Service) Delete

func (srv *Service) Delete(path string, f func(w http.ResponseWriter, r *http.Request))

Delete routes for DELETE requests of a defined path, the handle function.

func (*Service) Get

func (srv *Service) Get(path string, f func(w http.ResponseWriter, r *http.Request))

Get routes for GET requests of a defined path, the handle function and accepts a query parameter called "q". For large datasets, is a good practice use query parameter called "page", "limit" and "offset".

func (*Service) Post

func (srv *Service) Post(path string, f func(w http.ResponseWriter, r *http.Request))

Post routes for POST requests of a defined path, the handle function.

func (*Service) Put

func (srv *Service) Put(path string, f func(w http.ResponseWriter, r *http.Request))

Put routes for PUT requests of a defined path, the handle function.

Jump to

Keyboard shortcuts

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