From 0722f6cd4c10b34dfd49dc89d4b149f4719cbfe8 Mon Sep 17 00:00:00 2001 From: docktermj Date: Tue, 16 Jan 2024 14:45:55 -0500 Subject: [PATCH] #6 Prepare for versioned release --- CHANGELOG.md | 6 ++++++ go.mod | 5 ++--- go.sum | 10 ++++------ httpserver/httpserver.go | 20 ++++++++++++++++++-- 4 files changed, 30 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff4cbb0..6bb4c44 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.0.2] - 2024-01-16 + +### Added to 0.0.2 + +- Proxy for Senzing API server at `entity-search/api` + ## [0.0.1] - 2024-01-12 ### Added to 0.0.1 diff --git a/go.mod b/go.mod index ace3f2b..03ba094 100644 --- a/go.mod +++ b/go.mod @@ -38,13 +38,12 @@ require ( github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/ogen-go/ogen v0.81.1 // indirect github.com/pelletier/go-toml/v2 v2.1.1 // indirect github.com/prometheus/client_golang v1.18.0 // indirect github.com/prometheus/client_model v0.5.0 // indirect - github.com/prometheus/common v0.45.0 // indirect + github.com/prometheus/common v0.46.0 // indirect github.com/prometheus/procfs v0.12.0 // indirect github.com/russross/blackfriday/v2 v2.1.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect @@ -57,7 +56,7 @@ require ( github.com/senzing/g2-sdk-go v0.8.0 // indirect github.com/senzing/g2-sdk-go-base v0.4.0 // indirect github.com/senzing/g2-sdk-go-grpc v0.5.0 // indirect - github.com/senzing/g2-sdk-proto/go v0.0.0-20240110172410-a7cefad0f33e // indirect + github.com/senzing/g2-sdk-proto/go v0.0.0-20240115134958-8e806054968d // indirect github.com/senzing/go-sdk-abstract-factory v0.5.0 // indirect github.com/sirupsen/logrus v1.9.3 // indirect github.com/sourcegraph/conc v0.3.0 // indirect diff --git a/go.sum b/go.sum index d7ac52b..8090aa1 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,6 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0 h1:jWpvCLoY8Z/e3VKvlsiIGKtc+UG6U5vzxaoagmhXfyg= -github.com/matttproud/golang_protobuf_extensions/v2 v2.0.0/go.mod h1:QUyp042oQthUoa9bqDv0ER0wrtXnBruoNd7aNjkbP+k= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/ogen-go/ogen v0.81.1 h1:iIqsVxCeXrjS1a5ylqxwbSh4aJ2ZanJPAsDZmC9OijA= @@ -79,8 +77,8 @@ github.com/prometheus/client_golang v1.18.0 h1:HzFfmkOzH5Q8L8G+kSJKUx5dtG87sewO+ github.com/prometheus/client_golang v1.18.0/go.mod h1:T+GXkCk5wSJyOqMIzVgvvjFDlkOQntgjkJWKrN5txjA= github.com/prometheus/client_model v0.5.0 h1:VQw1hfvPvk3Uv6Qf29VrPF32JB6rtbgI6cYPYQjL0Qw= github.com/prometheus/client_model v0.5.0/go.mod h1:dTiFglRmd66nLR9Pv9f0mZi7B7fk5Pm3gvsjB5tr+kI= -github.com/prometheus/common v0.45.0 h1:2BGz0eBc2hdMDLnO/8n0jeB3oPrt2D08CekT0lneoxM= -github.com/prometheus/common v0.45.0/go.mod h1:YJmSTw9BoKxJplESWWxlbyttQR4uaEcGyv9MZjVOJsY= +github.com/prometheus/common v0.46.0 h1:doXzt5ybi1HBKpsZOL0sSkaNHJJqkyfEWZGGqqScV0Y= +github.com/prometheus/common v0.46.0/go.mod h1:Tp0qkxpb9Jsg54QMe+EAmqXkSV7Evdy1BTn+g2pa/hQ= github.com/prometheus/procfs v0.12.0 h1:jluTpSng7V9hY0O2R9DzzJHYb2xULk9VTR1V1R/k6Bo= github.com/prometheus/procfs v0.12.0/go.mod h1:pcuDEFsWDnvcgNzo4EEweacyhjeA9Zk3cnaOZAZEfOo= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= @@ -117,8 +115,8 @@ github.com/senzing/g2-sdk-go-base v0.4.0 h1:UdSpwY+wY8thKmRJ1t8KsnRWyEQQEu8SgAOl github.com/senzing/g2-sdk-go-base v0.4.0/go.mod h1:+odv+iRUY5h113T0c4SzKgy0dEbnYGPy+f2Z2U0iTeU= github.com/senzing/g2-sdk-go-grpc v0.5.0 h1:l1EB2yQFFUhi5pJUYfP2ROQyG3Hp8rVGsRFyehooG04= github.com/senzing/g2-sdk-go-grpc v0.5.0/go.mod h1:rDnRBJA/FgZjIrRQea9uGRZOSHQ4uObDZt+iRidFeyE= -github.com/senzing/g2-sdk-proto/go v0.0.0-20240110172410-a7cefad0f33e h1:1NkcjlZ/Z/bw2oA86PHSdSiPcJ0JE4VI7LpnSF1yAyg= -github.com/senzing/g2-sdk-proto/go v0.0.0-20240110172410-a7cefad0f33e/go.mod h1:Ux8LjqUsKd/Xie4i+2PHMulY2vlSubmmVatjQta3JqA= +github.com/senzing/g2-sdk-proto/go v0.0.0-20240115134958-8e806054968d h1:urvVlkRwML7e2qgLt0z6RrjHVhqfXmvEu+ajvF80FJU= +github.com/senzing/g2-sdk-proto/go v0.0.0-20240115134958-8e806054968d/go.mod h1:Ux8LjqUsKd/Xie4i+2PHMulY2vlSubmmVatjQta3JqA= github.com/senzing/go-sdk-abstract-factory v0.5.0 h1:heWbXpxm0oeKR0G8RDA69OLZEnsr7UP4javU42oYEhs= github.com/senzing/go-sdk-abstract-factory v0.5.0/go.mod h1:Kzt8To9fBTD8/MDoi+0q8p6h/cQ2iAF8P1dh0b5Ghxw= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= diff --git a/httpserver/httpserver.go b/httpserver/httpserver.go index f08bcd3..87f5040 100644 --- a/httpserver/httpserver.go +++ b/httpserver/httpserver.go @@ -148,7 +148,7 @@ func (httpServer *HttpServerImpl) populateStaticTemplate(responseWriter http.Res // --- http.ServeMux ---------------------------------------------------------- -func (httpServer *HttpServerImpl) getSenzingApiMux(ctx context.Context) *senzingrestapi.Server { +func (httpServer *HttpServerImpl) getSenzingApiGenericMux(ctx context.Context, urlRoutePrefix string) *senzingrestapi.Server { service := &senzingrestservice.SenzingRestServiceImpl{ GrpcDialOptions: httpServer.GrpcDialOptions, GrpcTarget: httpServer.GrpcTarget, @@ -158,7 +158,7 @@ func (httpServer *HttpServerImpl) getSenzingApiMux(ctx context.Context) *senzing SenzingEngineConfigurationJson: httpServer.SenzingEngineConfigurationJson, SenzingModuleName: httpServer.SenzingModuleName, SenzingVerboseLogging: httpServer.SenzingVerboseLogging, - UrlRoutePrefix: httpServer.ApiUrlRoutePrefix, + UrlRoutePrefix: urlRoutePrefix, OpenApiSpecificationSpec: httpServer.OpenApiSpecificationRest, } srv, err := senzingrestapi.NewServer(service, httpServer.ServerOptions...) @@ -168,6 +168,14 @@ func (httpServer *HttpServerImpl) getSenzingApiMux(ctx context.Context) *senzing return srv } +func (httpServer *HttpServerImpl) getSenzingApiMux(ctx context.Context) *senzingrestapi.Server { + return httpServer.getSenzingApiGenericMux(ctx, "/api") +} + +func (httpServer *HttpServerImpl) getSenzingApi2Mux(ctx context.Context) *senzingrestapi.Server { + return httpServer.getSenzingApiGenericMux(ctx, "/entity-search/api") +} + func (httpServer *HttpServerImpl) getEntitySearchMux(ctx context.Context) *http.ServeMux { service := &entitysearchservice.HttpServiceImpl{} return service.Handler(ctx) @@ -242,6 +250,14 @@ func (httpServer *HttpServerImpl) Serve(ctx context.Context) error { userMessage = fmt.Sprintf("%sServing Senzing REST API at http://localhost:%d/%s\n", userMessage, httpServer.ServerPort, httpServer.ApiUrlRoutePrefix) } + // Enable Senzing HTTP REST API as reverse proxy. + + if httpServer.EnableAll || httpServer.EnableSenzingRestAPI || httpServer.EnableEntitySearch { + senzingApiMux2 := httpServer.getSenzingApi2Mux(ctx) + rootMux.Handle("/entity-search/api/", http.StripPrefix("/entity-search/api", senzingApiMux2)) + userMessage = fmt.Sprintf("%sServing Senzing REST API Reverse Proxy at http://localhost:%d/%s\n", userMessage, httpServer.ServerPort, "entity-search/api") + } + // Enable Senzing Entity Search. if httpServer.EnableAll || httpServer.EnableEntitySearch {