api

package
v0.0.0-...-15cdbb1 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2023 License: Apache-2.0 Imports: 17 Imported by: 3 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsComponent

func AsComponent[T any](f any, paramTags string, resultTags string) any

func CtxWithUserUID

func CtxWithUserUID(ctx context.Context, uid interface{}) context.Context

CtxWithUserUID will return a context with UID stored as value.

func EncodeJSONResponse

func EncodeJSONResponse[T any](ctx context.Context, w http.ResponseWriter, response T) error

EncodeJSONResponse will take a given interface and encode the value as JSON

func NewRouter

func NewRouter(controllers []Controller) *mux.Router

func UserUIDFromCtx

func UserUIDFromCtx(ctx context.Context) string

UserUIDFromCtx will return user uid stored in context.

Types

type APIGatewayHandler

type APIGatewayHandler struct {
	// contains filtered or unexported fields
}

func (*APIGatewayHandler) Handle

type CRUD

type CRUD[T any] interface {
	Factory[T]
	Repository[T]
	Removal[T]
}

type CRUDLogger

type CRUDLogger[T any] struct{}

func NewCrudLogger

func NewCrudLogger[T any]() *CRUDLogger[T]

func (*CRUDLogger[T]) Create

func (l *CRUDLogger[T]) Create(ctx context.Context, t T, opts query.Opts) (T, error)

func (*CRUDLogger[T]) Delete

func (l *CRUDLogger[T]) Delete(ctx context.Context, id string) error

func (*CRUDLogger[T]) FindAll

func (l *CRUDLogger[T]) FindAll(ctx context.Context) ([]T, error)

func (*CRUDLogger[T]) FindByID

func (l *CRUDLogger[T]) FindByID(ctx context.Context, id string) (T, error)

func (*CRUDLogger[T]) Update

func (l *CRUDLogger[T]) Update(ctx context.Context, id string, t T) (T, error)

type Control

type Control struct {
	RootPath string
	Handlers []Handler
	// contains filtered or unexported fields
}

func (*Control) Mount

func (n *Control) Mount(mr *mux.Router)

func (*Control) Name

func (n *Control) Name() string

type Controller

type Controller interface {
	Mount(*mux.Router)
}

func NewCRUDController

func NewCRUDController[T any](name string, path string, svc CRUD[T]) Controller

func NewController

func NewController(root string, handlers []Handler) Controller

type Factory

type Factory[T any] interface {
	Create(context.Context, T) (T, error)
	Update(context.Context, string, T) (T, error)
}

type Handle

type Handle[T any] struct {
	Path        string
	RequestType string
	Handle      http.HandlerFunc
	// contains filtered or unexported fields
}

func NewCreateHandler

func NewCreateHandler[T any](name string, path string, factory Factory[T]) *Handle[T]

func NewFindAllHandler

func NewFindAllHandler[T any](name string, path string, repo Repository[T]) *Handle[T]

func NewFindByIDHandler

func NewFindByIDHandler[T any](name string, path string, repo Repository[T]) *Handle[T]

func NewGetHandler

func NewGetHandler[T any](name string, path string, fun http.HandlerFunc) *Handle[T]

func NewHandler

func NewHandler[T any](name string, path string, requestType string, fun http.HandlerFunc) *Handle[T]

func NewPostHandler

func NewPostHandler[T any](name string, path string, fun http.HandlerFunc) *Handle[T]

func (*Handle[T]) Mount

func (h *Handle[T]) Mount() (string, string, http.HandlerFunc)

func (*Handle[T]) Name

func (n *Handle[T]) Name() string

type Handler

type Handler interface {
	Mount() (string, string, http.HandlerFunc)
}

type LambdaHandler

func NewAPIGatewayHandler

func NewAPIGatewayHandler(router *mux.Router) LambdaHandler

type RESTApi

type RESTApi struct {
}

type Removal

type Removal[T any] interface {
	Delete(context.Context, string) error
}

type Repository

type Repository[T any] interface {
	FindAll(context.Context, query.Opts) ([]T, error)
	FindByID(context.Context, string) (T, error)
}

type Route

type Route interface {
	http.Handler
	Pattern() string
}

type Router

type Router struct {
	Controllers []Controller
	// contains filtered or unexported fields
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(debug ...bool) *Server

func (*Server) Register

func (s *Server) Register(i any)

func (*Server) RegisterAll

func (s *Server) RegisterAll(i []any)

func (*Server) Run

func (s *Server) Run()

Jump to

Keyboard shortcuts

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