Documentation
¶
Index ¶
- Variables
- func ApplyFilters[T any](list []T, opts *ListOpts) ([]T, error)
- func ApplySorts[T any](list []T, opts *ListOpts) ([]T, error)
- func ApplyWindow[T any](list []T, opts *ListOpts) ([]T, error)
- func Create[TOut, TIn any](ctx context.Context, api *API, obj *TIn) (*TOut, error)
- func CreateName[TOut, TIn any](ctx context.Context, api *API, name string, obj *TIn) (*TOut, error)
- func Delete[TOut any](ctx context.Context, api *API, id string, opts *UpdateOpts) error
- func DeleteName[TOut any](ctx context.Context, api *API, name, id string, opts *UpdateOpts) error
- func FieldChanged[T any](obj *T, prev *T, p string) bool
- func Find[TOut any](ctx context.Context, api *API, shortID string) (*TOut, error)
- func FindName[TOut any](ctx context.Context, api *API, name, shortID string) (*TOut, error)
- func Get[TOut any](ctx context.Context, api *API, id string, opts *GetOpts) (*TOut, error)
- func GetName[TOut any](ctx context.Context, api *API, name, id string, opts *GetOpts) (*TOut, error)
- func IsCreate[T any](obj *T, prev *T) bool
- func IsDelete[T any](obj *T, prev *T) bool
- func IsUpdate[T any](obj *T, prev *T) bool
- func List[TOut any](ctx context.Context, api *API, opts *ListOpts) ([]*TOut, error)
- func ListName[TOut any](ctx context.Context, api *API, name string, opts *ListOpts) ([]*TOut, error)
- func P[T any](v T) *T
- func Register[T any](api *API)
- func RegisterName[T any](api *API, typeName string)
- func Replace[TOut, TIn any](ctx context.Context, api *API, id string, obj *TIn, opts *UpdateOpts) (*TOut, error)
- func ReplaceName[TOut, TIn any](ctx context.Context, api *API, name, id string, obj *TIn, opts *UpdateOpts) (*TOut, error)
- func SetAuthBasic[T any](api *API, pathUser, pathPass string)
- func SetAuthBasicName[T any](api *API, name, pathUser, pathPass string)
- func SetAuthBearer[T any](api *API, pathToken string)
- func SetAuthBearerName[T any](api *API, name, pathToken string)
- func SetListHook[T any](api *API, hook ListHook)
- func SetListHookName[T any](api *API, name string, hook ListHook)
- func Update[TOut, TIn any](ctx context.Context, api *API, id string, obj *TIn, opts *UpdateOpts) (*TOut, error)
- func UpdateName[TOut, TIn any](ctx context.Context, api *API, name, id string, obj *TIn, opts *UpdateOpts) (*TOut, error)
- type API
- func (api *API) Addr() *net.TCPAddr
- func (api *API) CheckSafe()
- func (api *API) Close()
- func (api *API) Handle(method, path string, handler httprouter.Handle)
- func (api *API) Handler(method, path string, handler http.Handler)
- func (api *API) HandlerFunc(method, path string, handler http.HandlerFunc)
- func (api *API) IsSafe() error
- func (api *API) ListenInsecure(bind string) error
- func (api *API) ListenSelfCert(bind string) error
- func (api *API) ListenTLS(bind, certFile, keyFile string) error
- func (api *API) Serve() error
- func (api *API) ServeFiles(path string, fs http.FileSystem)
- func (api *API) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (api *API) SetOpenAPIInfo(info *OpenAPIInfo)
- func (api *API) SetRequestHook(hook RequestHook)
- func (api *API) SetStripPrefix(prefix string)
- func (api *API) Shutdown(ctx context.Context) error
- type ContextKey
- type DebugInfo
- type Filter
- type GetOpts
- type GetStream
- type HTTPInfo
- type IPInfo
- type ListHook
- type ListOpts
- type ListStream
- type Metadata
- type OpenAPI
- type OpenAPIInfo
- type RequestHook
- type ServerInfo
- type TLSInfo
- type UpdateOpts
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrHeaderValueMissingQuotes = errors.New("header missing quotes") ErrUnknownAcceptType = errors.New("unknown Accept type") )
View Source
var ( ErrInvalidIfNoneMatch = errors.New("invalid If-None-Match") ErrIfNoneMatchUnknownType = fmt.Errorf("unknown type (%w)", ErrInvalidIfNoneMatch) ErrIfNoneMatchInvalidGeneration = fmt.Errorf("invalid generation (%w)", ErrInvalidIfNoneMatch) )
View Source
var ( ErrInvalidFilterOp = errors.New("invalid filter operator") ErrInvalidSort = errors.New("invalid _sort") ErrInvalidStreamFormat = errors.New("invalid _stream") )
View Source
var ErrMissingAuthCheck = errors.New("missing auth check")
View Source
var ErrStreamingNotSupported = errors.New("streaming not supported")
Functions ¶
func ApplyFilters ¶
func ApplySorts ¶
func ApplyWindow ¶
func CreateName ¶
func DeleteName ¶
func FieldChanged ¶
func RegisterName ¶
func ReplaceName ¶
func SetAuthBasic ¶
func SetAuthBasicName ¶
func SetAuthBearer ¶
func SetAuthBearerName ¶
func SetListHook ¶
func UpdateName ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
func (*API) HandlerFunc ¶
func (api *API) HandlerFunc(method, path string, handler http.HandlerFunc)
func (*API) ListenInsecure ¶
func (*API) ListenSelfCert ¶
func (*API) ServeFiles ¶
func (api *API) ServeFiles(path string, fs http.FileSystem)
func (*API) SetOpenAPIInfo ¶
func (api *API) SetOpenAPIInfo(info *OpenAPIInfo)
func (*API) SetRequestHook ¶
func (api *API) SetRequestHook(hook RequestHook)
func (*API) SetStripPrefix ¶
type ContextKey ¶
type ContextKey int
const ( ContextInternal ContextKey = iota ContextAuthBearer ContextAuthBasic )
type DebugInfo ¶
type DebugInfo struct { Server *ServerInfo `json:"server"` IP *IPInfo `json:"ip"` HTTP *HTTPInfo `json:"http"` TLS *TLSInfo `json:"tls"` }
type GetOpts ¶
type GetOpts struct { IfNoneMatch []httpheader.EntityTag // This is "any" because making GetOpts generic complicates too many things Prev any }
type GetStream ¶
type GetStream[T any] struct { // contains filtered or unexported fields }
func StreamGetName ¶
type ListStream ¶
type ListStream[T any] struct { // contains filtered or unexported fields }
func StreamList ¶
func StreamListName ¶
func (*ListStream[T]) Chan ¶
func (ls *ListStream[T]) Chan() <-chan []*T
func (*ListStream[T]) Close ¶
func (ls *ListStream[T]) Close()
func (*ListStream[T]) Error ¶
func (ls *ListStream[T]) Error() error
func (*ListStream[T]) Read ¶
func (ls *ListStream[T]) Read() []*T
type OpenAPIInfo ¶
type ServerInfo ¶
type ServerInfo struct {
Hostname string `json:"hostname"`
}
type UpdateOpts ¶
type UpdateOpts struct { IfMatch []httpheader.EntityTag // This is "any" because making UpdateOpts generic complicates too many things Prev any }
Click to show internal directories.
Click to hide internal directories.