mirror of
https://github.com/bitechdev/ResolveSpec.git
synced 2025-12-31 17:28:58 +00:00
Added meta operation.
This commit is contained in:
@@ -151,6 +151,8 @@ func (h *Handler) Handle(w common.ResponseWriter, r common.Request, params map[s
|
||||
h.handleUpdate(ctx, w, id, req.ID, req.Data, req.Options)
|
||||
case "delete":
|
||||
h.handleDelete(ctx, w, id, req.Data)
|
||||
case "meta":
|
||||
h.handleMeta(ctx, w, schema, entity, model)
|
||||
default:
|
||||
logger.Error("Invalid operation: %s", req.Operation)
|
||||
h.sendError(w, http.StatusBadRequest, "invalid_operation", "Invalid operation", nil)
|
||||
@@ -188,6 +190,21 @@ func (h *Handler) HandleGet(w common.ResponseWriter, r common.Request, params ma
|
||||
h.sendResponse(w, metadata, nil)
|
||||
}
|
||||
|
||||
// handleMeta processes meta operation requests
|
||||
func (h *Handler) handleMeta(ctx context.Context, w common.ResponseWriter, schema, entity string, model interface{}) {
|
||||
// Capture panics and return error response
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
h.handlePanic(w, "handleMeta", err)
|
||||
}
|
||||
}()
|
||||
|
||||
logger.Info("Getting metadata for %s.%s via meta operation", schema, entity)
|
||||
|
||||
metadata := h.generateMetadata(schema, entity, model)
|
||||
h.sendResponse(w, metadata, nil)
|
||||
}
|
||||
|
||||
func (h *Handler) handleRead(ctx context.Context, w common.ResponseWriter, id string, options common.RequestOptions) {
|
||||
// Capture panics and return error response
|
||||
defer func() {
|
||||
|
||||
Reference in New Issue
Block a user