From 33b52f69ec4e4d90b789c8262df78216c42efd2a Mon Sep 17 00:00:00 2001 From: Matthew Rich Date: Sat, 28 Sep 2024 19:50:24 +0000 Subject: [PATCH] fix network route schema; fix setting the config block for the http resource --- internal/resource/http.go | 8 +++++--- internal/resource/schemas/network-route.schema.json | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/internal/resource/http.go b/internal/resource/http.go index 16e4513..5878132 100644 --- a/internal/resource/http.go +++ b/internal/resource/http.go @@ -33,7 +33,7 @@ var ( ) func init() { - ResourceTypes.Register([]string{"http", "https"}, HTTPFactory) + folio.DocumentRegistry.ResourceTypes.Register([]string{"http", "https"}, HTTPFactory) } func HTTPFactory(u *url.URL) data.Resource { @@ -79,13 +79,15 @@ type HTTP struct { } func NewHTTP() *HTTP { - return &HTTP{ client: &http.Client{}, Common: &Common{ includeQueryParamsInURI: true, resourceType: HTTPTypeName, SchemeCheck: func(scheme string) bool { + h := &HTTP{ client: &http.Client{}, Common: &Common{ includeQueryParamsInURI: true, resourceType: HTTPTypeName, SchemeCheck: func(scheme string) bool { switch scheme { case "http", "https": return true } return false } } } + slog.Info("NewHTTP()", "http", h) + return h } func (h *HTTP) SetResourceMapper(resources data.ResourceMapper) { @@ -320,7 +322,7 @@ func (h *HTTP) Create(ctx context.Context) (err error) { } } - slog.Error("HTTP.Create()", "http", h) + slog.Error("HTTP.Create()", "http", h, "reader", h.reader) copyBuffer := make([]byte, 32 * 1024) _, writeErr := io.CopyBuffer(h.writer, contentReader, copyBuffer) diff --git a/internal/resource/schemas/network-route.schema.json b/internal/resource/schemas/network-route.schema.json index 035d329..0ed9e86 100644 --- a/internal/resource/schemas/network-route.schema.json +++ b/internal/resource/schemas/network-route.schema.json @@ -3,7 +3,7 @@ "$schema": "http://json-schema.org/draft-07/schema#", "title": "network-route", "type": "object", - "required": [ "to", "gateway", "interface", "rtid", "metric", "type", "scope" ], + "required": [ "to", "gateway", "interface", "rtid", "metric", "routetype", "scope" ], "properties": { "to": { "type": "string" @@ -24,7 +24,7 @@ "description": "Network route metric", "minimum": 0 }, - "type": { + "routetype": { "type": "string", "description": "Network route type", "pattern": "^(unicast|local|broadcast|multicast|throw|unreachable|prohibit|blackhole|nat|[0-9]+)$"