@@ -117,37 +117,6 @@ func getDatabaseDetails(database knowledge.GraphDB) http.HandlerFunc {
117
117
}
118
118
}
119
119
120
- func getGraphRead (registry sources.Registry , graphDB knowledge.GraphDB ) http.HandlerFunc {
121
- return func (w http.ResponseWriter , r * http.Request ) {
122
- ok , source , err := handlers .IsTokenValid (registry , r )
123
- if err != nil {
124
- handlers .ReplyWithInternalError (w , err )
125
- return
126
- }
127
-
128
- if ! ok {
129
- handlers .ReplyWithUnauthorized (w )
130
- return
131
- }
132
-
133
- g := knowledge .NewGraph ()
134
- if err := graphDB .ReadGraph (r .Context (), source , g ); err != nil {
135
- handlers .ReplyWithInternalError (w , err )
136
- return
137
- }
138
-
139
- gJSON , err := json .Marshal (g )
140
- if err != nil {
141
- handlers .ReplyWithInternalError (w , err )
142
- return
143
- }
144
-
145
- if _ , err := w .Write (gJSON ); err != nil {
146
- handlers .ReplyWithInternalError (w , err )
147
- }
148
- }
149
- }
150
-
151
120
func flushDatabase (graphDB knowledge.GraphDB ) http.HandlerFunc {
152
121
return func (w http.ResponseWriter , r * http.Request ) {
153
122
if err := graphDB .FlushAll (r .Context ()); err != nil {
@@ -176,7 +145,7 @@ func StartServer(listenInterface string,
176
145
schemaPersistor schema.Persistor ,
177
146
sourcesRegistry sources.Registry ,
178
147
queryHistorizer history.Historizer ,
179
- concurrency int64 ) {
148
+ writeConcurrency int64 ) {
180
149
181
150
r := mux .NewRouter ()
182
151
@@ -213,9 +182,9 @@ func StartServer(listenInterface string,
213
182
214
183
r .Handle ("/metrics" , promhttp .Handler ())
215
184
216
- r .HandleFunc ("/api/graph/read" , getGraphRead (sourcesRegistry , database )).Methods ("GET" )
185
+ r .HandleFunc ("/api/graph/read" , handlers . GetGraphRead (sourcesRegistry , database )).Methods ("GET" )
217
186
218
- sem := semaphore .NewWeighted (concurrency )
187
+ sem := semaphore .NewWeighted (writeConcurrency )
219
188
220
189
r .HandleFunc ("/api/graph/schema" , handlers .PutSchema (sourcesRegistry , graphUpdater , sem )).Methods ("PUT" )
221
190
r .HandleFunc ("/api/graph/assets" , handlers .PutAssets (sourcesRegistry , graphUpdater , sem )).Methods ("PUT" )
@@ -230,12 +199,12 @@ func StartServer(listenInterface string,
230
199
231
200
var err error
232
201
if viper .GetString ("server_tls_cert" ) != "" {
233
- logrus .Infof ("Listening on %s with TLS enabled, the connection is secure [concurrency=%d" , listenInterface , concurrency )
202
+ logrus .Infof ("Listening on %s with TLS enabled, the connection is secure [concurrency=%d" , listenInterface , writeConcurrency )
234
203
err = http .ListenAndServeTLS (listenInterface , viper .GetString ("server_tls_cert" ),
235
204
viper .GetString ("server_tls_key" ), r )
236
205
} else {
237
206
logrus .Warnf ("Listening on %s with TLS disabled. Use `server_tls_cert` option to setup a certificate [concurrency=%d]" ,
238
- listenInterface , concurrency )
207
+ listenInterface , writeConcurrency )
239
208
err = http .ListenAndServe (listenInterface , r )
240
209
}
241
210
if err != nil {
0 commit comments