xrest

package
v0.0.0-...-ac9ea8b Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GenErr     uint = 1 // Unclassified error
	BadRequest uint = 2 // Error parsing request data
	BadResp    uint = 3 // Error generating response
)

Variables

View Source
var TraceFn func(context.Context, interface{})

Functions

This section is empty.

Types

type Factory

type Factory interface {
	Get(context.Context, *http.Request) (Obj, *ReqErr)
	Create(context.Context, interface{}) (Obj, *ReqErr)
	Iterate(context.Context, url.Values, func(context.Context, Obj) *ReqErr) *ReqErr
}

type Obj

type Obj interface {
	Info(context.Context, url.Values, bool) (interface{}, *ReqErr)
	Del(context.Context) *ReqErr
	Upd(context.Context, interface{}) *ReqErr
	Add(context.Context, interface{}) *ReqErr
}

type Prop

type Prop interface {
	Info(context.Context, Obj, url.Values) (interface{}, *ReqErr)
	Upd(context.Context, Obj, interface{}) *ReqErr
}

type ReqErr

type ReqErr struct {
	Code    uint   `json:"code"`
	Message string `json:"message"`
}

func HandleCreateOne

func HandleCreateOne(ctx context.Context, w http.ResponseWriter, r *http.Request, fact Factory, add interface{}) *ReqErr

func HandleDeleteOne

func HandleDeleteOne(ctx context.Context, w http.ResponseWriter, r *http.Request, desc Obj) *ReqErr

func HandleGetList

func HandleGetList(ctx context.Context, w http.ResponseWriter, r *http.Request, fact Factory) *ReqErr

func HandleGetOne

func HandleGetOne(ctx context.Context, w http.ResponseWriter, r *http.Request, desc Obj) *ReqErr

func HandleGetProp

func HandleGetProp(ctx context.Context, w http.ResponseWriter, r *http.Request, o Obj, desc Prop) *ReqErr

func HandleMany

func HandleMany(ctx context.Context, w http.ResponseWriter, r *http.Request, f Factory, add_param interface{}) *ReqErr

func HandleOne

func HandleOne(ctx context.Context, w http.ResponseWriter, r *http.Request, f Factory, upd_param interface{}) *ReqErr

func HandleProp

func HandleProp(ctx context.Context, w http.ResponseWriter, r *http.Request, f Factory, p Prop, upd_param interface{}) *ReqErr

func HandleUpdateOne

func HandleUpdateOne(ctx context.Context, w http.ResponseWriter, r *http.Request, desc Obj, upd interface{}) *ReqErr

func HandleUpdateProp

func HandleUpdateProp(ctx context.Context, w http.ResponseWriter, r *http.Request, o Obj, desc Prop, upd interface{}) *ReqErr

func Respond

func Respond(ctx context.Context, w http.ResponseWriter, result interface{}) *ReqErr

func (*ReqErr) String

func (re *ReqErr) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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