/
connections_handlers.go
600 lines (520 loc) · 20.6 KB
/
connections_handlers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
package handlers
import (
"encoding/json"
"fmt"
"io"
"net/http"
"strconv"
"strings"
"github.com/gofrs/uuid"
"github.com/gorilla/mux"
"github.com/khulnasoft/meshplay/server/machines"
"github.com/khulnasoft/meshplay/server/machines/helpers"
"github.com/khulnasoft/meshplay/server/machines/kubernetes"
"github.com/khulnasoft/meshplay/server/models"
"github.com/khulnasoft/meshplay/server/models/connections"
"github.com/khulnasoft/meshkit/models/events"
"github.com/khulnasoft/meshkit/models/meshmodel/core/v1alpha1"
)
type connectionStatusPayload map[uuid.UUID]connections.ConnectionStatus
func (h *Handler) ProcessConnectionRegistration(w http.ResponseWriter, req *http.Request, prefObj *models.Preference, user *models.User, provider models.Provider) {
if req.Method == http.MethodDelete {
h.handleProcessTermination(w, req)
return
}
connectionRegisterPayload := models.ConnectionPayload{}
userUUID := uuid.FromStringOrNil(user.ID)
err := json.NewDecoder(req.Body).Decode(&connectionRegisterPayload)
if err != nil {
http.Error(w, models.ErrUnmarshal(err, "connection registration payload").Error(), http.StatusInternalServerError)
return
}
eventBuilder := events.NewEvent().ActedUpon(userUUID).WithCategory("connection").WithAction("update").FromSystem(*h.SystemID).FromUser(userUUID).WithDescription("Failed to interact with the connection.")
if string(connectionRegisterPayload.Status) == string(machines.Init) {
h.handleRegistrationInitEvent(w, req, &connectionRegisterPayload)
} else {
smInstanceTracker := h.ConnectionToStateMachineInstanceTracker
machineCtx := make(map[string]string, 0)
inst, err := helpers.InitializeMachineWithContext(
machineCtx,
req.Context(),
connectionRegisterPayload.ID,
userUUID,
smInstanceTracker,
h.log,
provider,
machines.DISCOVERED,
strings.ToLower(connectionRegisterPayload.Kind),
nil,
)
if err != nil {
event := eventBuilder.WithSeverity(events.Error).WithDescription("Unable to perisit the \"%s\" connection details").WithMetadata(map[string]interface{}{
"error": err,
}).Build()
_ = provider.PersistEvent(event)
go h.config.EventBroadcaster.Publish(userUUID, event)
}
event, err := inst.SendEvent(req.Context(), machines.EventType(connectionRegisterPayload.Status), connectionRegisterPayload)
if err != nil {
h.log.Error(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
_ = provider.PersistEvent(event)
go h.config.EventBroadcaster.Publish(userUUID, event)
}
}
}
func (h *Handler) handleProcessTermination(w http.ResponseWriter, req *http.Request) {
body := make(map[string]string, 0)
err := json.NewDecoder(req.Body).Decode(&body)
if err != nil {
_err := models.ErrUnmarshal(err, "request body")
h.log.Error(_err)
http.Error(w, _err.Error(), http.StatusInternalServerError)
return
}
smInstancetracker := h.ConnectionToStateMachineInstanceTracker
id, ok := body["id"]
if ok {
smInstancetracker.Remove(uuid.FromStringOrNil(id))
}
}
func (h *Handler) handleRegistrationInitEvent(w http.ResponseWriter, req *http.Request, payload *models.ConnectionPayload) {
compFilter := &v1alpha1.ComponentFilter{
Name: fmt.Sprintf("%sConnection", payload.Kind),
Limit: 1,
}
schema := make(map[string]interface{}, 1)
connectionComponent, _, _ := h.registryManager.GetEntities(compFilter)
if len(connectionComponent) == 0 {
http.Error(w, "Unable to register resource as connection. No matching connection definition found in the registry", http.StatusInternalServerError)
return
}
schema["connection"] = connectionComponent[0]
credential, _, _ := h.registryManager.GetEntities(&v1alpha1.ComponentFilter{
Name: fmt.Sprintf("%sCredential", payload.Kind),
Limit: 1,
})
if len(credential) > 0 {
schema["credential"] = credential[0]
}
// id act as a connection registration process tracker.
// The clients should always include this "id" in the subsequent API calls until the process is completed or terminated.
id, _ := uuid.NewV4()
schema["id"] = id
err := json.NewEncoder(w).Encode(&schema)
if err != nil {
h.log.Error(ErrWriteResponse)
}
}
// swagger:route POST /api/integrations/connections PostConnection idPostConnection
// Handle POST request for creating a new connection
//
// Creates a new connection
// responses:
// 201: noContentWrapper
func (h *Handler) SaveConnection(w http.ResponseWriter, req *http.Request, _ *models.Preference, user *models.User, provider models.Provider) {
bd, err := io.ReadAll(req.Body)
userID := uuid.FromStringOrNil(user.ID)
if err != nil {
h.log.Error(ErrRequestBody(err))
http.Error(w, ErrRequestBody(err).Error(), http.StatusInternalServerError)
return
}
connection := models.ConnectionPayload{}
err = json.Unmarshal(bd, &connection)
obj := "connection"
if err != nil {
h.log.Error(models.ErrUnmarshal(err, obj))
http.Error(w, models.ErrUnmarshal(err, obj).Error(), http.StatusInternalServerError)
return
}
eventBuilder := events.NewEvent().ActedUpon(userID).FromUser(userID).FromSystem(*h.SystemID).WithCategory("connection").WithAction("create")
_, err = provider.SaveConnection(&connection, "", false)
if err != nil {
_err := ErrFailToSave(err, obj)
metadata := map[string]interface{}{
"error": _err,
}
event := eventBuilder.WithSeverity(events.Error).WithDescription(fmt.Sprintf("Error creating connection %s", connection.Name)).WithMetadata(metadata).Build()
_ = provider.PersistEvent(event)
go h.config.EventBroadcaster.Publish(userID, event)
h.log.Error(_err)
http.Error(w, _err.Error(), http.StatusInternalServerError)
return
}
description := fmt.Sprintf("Connection %s created.", connection.Name)
event := eventBuilder.WithSeverity(events.Informational).WithDescription(description).Build()
_ = provider.PersistEvent(event)
go h.config.EventBroadcaster.Publish(userID, event)
h.log.Info(description)
w.WriteHeader(http.StatusCreated)
}
// swagger:route GET /api/integrations/connections GetConnections idGetConnections
// Handle GET request for getting all connections
//
// ```?order={field}``` orders on the passed field
//
// ```?search={}``` If search is non empty then a greedy search is performed
//
// ```?page={page-number}``` Default page number is 0
//
// ```?pagesize={pagesize}``` Default pagesize is 10
//
// ```?filter={filter}``` Filter connections with type or sub_type, eg /api/integrations/connections?filter=type%20platform or /api/integrations/connections?filter=sub_type%20management
//
// ```?status={status}``` Status takes array as param to filter connections based on status, eg /api/integrations/connections?status=["connected", "deleted"]
//
// ```?kind={kind}``` Kind takes array as param to filter connections based on kind, eg /api/integrations/connections?kind=["meshplay", "kubernetes"]
// responses:
// 200: meshplayConnectionsResponseWrapper
func (h *Handler) GetConnections(w http.ResponseWriter, req *http.Request, prefObj *models.Preference, user *models.User, provider models.Provider) {
q := req.URL.Query()
page, _ := strconv.Atoi(q.Get("page"))
order := q.Get("order")
search := q.Get("search")
pageSize, _ := strconv.Atoi(q.Get("pagesize"))
filter := q.Get("filter")
if pageSize > 50 {
pageSize = 50
}
if pageSize <= 0 {
pageSize = 10
}
if page < 0 {
page = 0
}
if order == "" {
order = "updated_at desc"
}
err := req.ParseForm()
if err != nil {
h.log.Error(ErrGetConnections(err))
http.Error(w, ErrGetConnections(err).Error(), http.StatusInternalServerError)
return
}
queryParam := struct {
Status []string `json:"status"`
Kind []string `json:"kind"`
}{}
status := q.Get("status")
kind := q.Get("kind")
if status != "" {
err := json.Unmarshal([]byte(status), &queryParam.Status)
if err != nil {
h.log.Error(ErrGetConnections(err))
http.Error(w, ErrGetConnections(err).Error(), http.StatusInternalServerError)
return
}
}
if kind != "" {
err := json.Unmarshal([]byte(kind), &queryParam.Kind)
if err != nil {
h.log.Error(ErrGetConnections(err))
http.Error(w, ErrGetConnections(err).Error(), http.StatusInternalServerError)
return
}
}
connectionsPage, err := provider.GetConnections(req, user.ID, page, pageSize, search, order, filter, queryParam.Status, queryParam.Kind)
obj := "connections"
if err != nil {
h.log.Error(ErrQueryGet(obj))
http.Error(w, ErrQueryGet(obj).Error(), http.StatusInternalServerError)
return
}
if err := json.NewEncoder(w).Encode(connectionsPage); err != nil {
h.log.Error(models.ErrEncoding(err, obj))
http.Error(w, models.ErrEncoding(err, obj).Error(), http.StatusInternalServerError)
return
}
}
// swagger:route GET /api/integrations/connections/{connectionKind} GetConnectionsByKind idGetConnectionsByKind
// Handle GET request for getting all connections for a given kind.
//
// ```?order={field}``` orders on the passed field
//
// ```?search={}``` If search is non empty then a greedy search is performed
//
// ```?page={page-number}``` Default page number is 0
//
// ```?pagesize={pagesize}``` Default pagesize is 10
// responses:
// 200: ConnectionPage
func (h *Handler) GetConnectionsByKind(w http.ResponseWriter, req *http.Request, _ *models.Preference, user *models.User, provider models.Provider) {
q := req.URL.Query()
connectionKind := mux.Vars(req)["connectionKind"]
page, _ := strconv.Atoi(q.Get("page"))
order := q.Get("order")
search := q.Get("search")
pageSize, _ := strconv.Atoi(q.Get("pagesize"))
if pageSize > 25 {
pageSize = 25
}
if pageSize <= 0 {
pageSize = 10
}
if page < 0 {
page = 0
}
if order == "" {
order = "updated_at desc"
}
h.log.Debug(fmt.Sprintf("page: %d, page size: %d, search: %s, order: %s", page+1, pageSize, search, order))
connectionsPage, err := provider.GetConnectionsByKind(req, user.ID, page, pageSize, search, order, connectionKind)
obj := "connections"
if err != nil {
h.log.Error(err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if err := json.NewEncoder(w).Encode(connectionsPage); err != nil {
h.log.Error(models.ErrEncoding(err, obj))
http.Error(w, models.ErrEncoding(err, obj).Error(), http.StatusInternalServerError)
return
}
}
// swagger:route GET /api/integrations/connections/status GetConnectionsStatus idGetConnectionsStatus
// Handle GET request for getting all connections status
//
// Get all connections status
// responses:
// 200: meshplayConnectionsStatusPage
func (h *Handler) GetConnectionsStatus(w http.ResponseWriter, req *http.Request, _ *models.Preference, user *models.User, provider models.Provider) {
connectionsStatusPage, err := provider.GetConnectionsStatus(req, user.ID)
obj := "connections status"
if err != nil {
h.log.Error(ErrQueryGet(obj))
http.Error(w, ErrQueryGet(obj).Error(), http.StatusInternalServerError)
return
}
if err := json.NewEncoder(w).Encode(connectionsStatusPage); err != nil {
h.log.Error(models.ErrEncoding(err, obj))
http.Error(w, models.ErrEncoding(err, obj).Error(), http.StatusInternalServerError)
return
}
}
func (h *Handler) UpdateConnectionStatus(w http.ResponseWriter, req *http.Request, _ *models.Preference, user *models.User, provider models.Provider) {
connectionStatusPayload := &connectionStatusPayload{}
defer func() {
_ = req.Body.Close()
}()
userID := uuid.FromStringOrNil(user.ID)
eventBuilder := events.NewEvent().FromSystem(*h.SystemID).FromUser(userID).WithCategory("connection").WithAction("update").ActedUpon(userID)
err := json.NewDecoder(req.Body).Decode(connectionStatusPayload)
if err != nil {
errUnmarshal := models.ErrUnmarshal(err, "connection status payload")
eventBuilder.WithSeverity(events.Error).WithDescription("Unable to update connection status.").
WithMetadata(map[string]interface{}{
"error": errUnmarshal,
})
event := eventBuilder.Build()
_ = provider.PersistEvent(event)
go h.config.EventBroadcaster.Publish(userID, event)
return
}
connKind := mux.Vars(req)["connectionKind"]
if connKind == "kubernetes" {
smInstanceTracker := h.ConnectionToStateMachineInstanceTracker
token, _ := req.Context().Value(models.TokenCtxKey).(string)
for id, status := range *connectionStatusPayload {
eventBuilder.ActedUpon(id)
k8scontext, err := provider.GetK8sContext(token, id.String())
if err != nil {
eventBuilder.WithSeverity(events.Error).WithDescription(fmt.Sprintf("Failed to update connection status for %s", id)).WithMetadata(map[string]interface{}{
"error": err,
})
_event := eventBuilder.Build()
_ = provider.PersistEvent(_event)
go h.config.EventBroadcaster.Publish(userID, _event)
continue
}
event := eventBuilder.WithSeverity(events.Informational).
WithDescription(fmt.Sprintf("Processing status update to \"%s\" for connection %s", status, k8scontext.Name)).Build()
_ = provider.PersistEvent(event)
go h.config.EventBroadcaster.Publish(userID, event)
machineCtx := &kubernetes.MachineCtx{
K8sContext: k8scontext,
MeshplayCtrlsHelper: h.MeshplayCtrlsHelper,
K8sCompRegHelper: h.K8sCompRegHelper,
OperatorTracker: h.config.OperatorTracker,
K8scontextChannel: h.config.K8scontextChannel,
EventBroadcaster: h.config.EventBroadcaster,
RegistryManager: h.registryManager,
}
inst, err := helpers.InitializeMachineWithContext(
machineCtx,
req.Context(),
id,
userID,
smInstanceTracker,
h.log,
provider,
machines.InitialState,
"kubernetes",
kubernetes.AssignInitialCtx,
)
if err != nil {
event := eventBuilder.WithSeverity(events.Error).WithDescription(fmt.Sprintf("Failed to update connection status for %s", id)).WithMetadata(map[string]interface{}{
"error": err,
}).Build()
_ = provider.PersistEvent(event)
go h.config.EventBroadcaster.Publish(userID, event)
continue
}
go func(inst *machines.StateMachine, status connections.ConnectionStatus) {
event, err = inst.SendEvent(req.Context(), machines.EventType(helpers.StatusToEvent(status)), nil)
if err != nil {
h.log.Error(err)
_ = provider.PersistEvent(event)
h.config.EventBroadcaster.Publish(userID, event)
return
}
if status == connections.DELETED {
smInstanceTracker.Remove(inst.ID)
}
_ = provider.PersistEvent(event)
h.config.EventBroadcaster.Publish(userID, event)
}(inst, status)
}
} else {
token, _ := req.Context().Value(models.TokenCtxKey).(string)
for id, status := range *connectionStatusPayload {
connection, statusCode, err := provider.UpdateConnectionStatusByID(token, id, status)
if err != nil {
event := events.NewEvent().WithCategory("connection").WithAction("update").WithSeverity(events.Error).ActedUpon(id).FromUser(userID).FromSystem(*h.SystemID).WithDescription(fmt.Sprintf("Unable to update connection status to %s", status)).WithMetadata(map[string]interface{}{"error": err}).Build()
_ = provider.PersistEvent(event)
h.config.EventBroadcaster.Publish(userID, event)
h.log.Error(err)
continue
}
eb := events.NewEvent()
eb.WithDescription(fmt.Sprintf("Connection \"%s\" status updated to %s", connection.Name, connection.Status)).WithAction("update")
if status == connections.DELETED {
eb.WithDescription(fmt.Sprintf("Connection \"%s\" deleted", connection.Name)).WithAction("delete")
}
event := eb.WithCategory("connection").WithSeverity(events.Success).FromUser(userID).FromSystem(*h.SystemID).ActedUpon(id).Build()
_ = provider.PersistEvent(event)
h.config.EventBroadcaster.Publish(userID, event)
h.log.Debug("connection", connection, statusCode)
}
}
w.WriteHeader(http.StatusAccepted)
}
// swagger:route PUT /api/integrations/connections/{connectionKind} PutConnection idPutConnection
// Handle PUT request for updating an existing connection
//
// Updates existing connection
// responses:
// 200: noContentWrapper
func (h *Handler) UpdateConnection(w http.ResponseWriter, req *http.Request, _ *models.Preference, user *models.User, provider models.Provider) {
bd, err := io.ReadAll(req.Body)
if err != nil {
h.log.Error(ErrRequestBody(err))
http.Error(w, ErrRequestBody(err).Error(), http.StatusInternalServerError)
return
}
userID := uuid.FromStringOrNil(user.ID)
connection := &connections.Connection{}
err = json.Unmarshal(bd, connection)
obj := "connection"
if err != nil {
h.log.Error(models.ErrUnmarshal(err, obj))
http.Error(w, models.ErrUnmarshal(err, obj).Error(), http.StatusInternalServerError)
return
}
connectionID := connection.ID
eventBuilder := events.NewEvent().ActedUpon(connectionID).FromUser(userID).FromSystem(*h.SystemID).WithCategory("connection").WithAction("update")
updatedConnection, err := provider.UpdateConnection(req, connection)
if err != nil {
_err := ErrFailToSave(err, obj)
metadata := map[string]interface{}{
"error": _err,
}
event := eventBuilder.WithSeverity(events.Error).WithDescription("Error updating connection").WithMetadata(metadata).Build()
_ = provider.PersistEvent(event)
go h.config.EventBroadcaster.Publish(userID, event)
h.log.Error(_err)
http.Error(w, _err.Error(), http.StatusInternalServerError)
return
}
description := fmt.Sprintf("Connection %s updated.", updatedConnection.Name)
event := eventBuilder.WithSeverity(events.Informational).WithDescription(description).Build()
_ = provider.PersistEvent(event)
go h.config.EventBroadcaster.Publish(userID, event)
h.log.Info(description)
w.WriteHeader(http.StatusOK)
}
// swagger:route PUT /api/integrations/connections/{connectionId} PutConnectionById idPutConnectionById
// Handle PUT request for updating an existing connection by connection ID
//
// Updates existing connection using ID
// responses:
// 200: meshplayConnectionResponseWrapper
func (h *Handler) UpdateConnectionById(w http.ResponseWriter, req *http.Request, _ *models.Preference, user *models.User, provider models.Provider) {
connectionID := uuid.FromStringOrNil(mux.Vars(req)["connectionId"])
userID := uuid.FromStringOrNil(user.ID)
bd, err := io.ReadAll(req.Body)
if err != nil {
h.log.Error(ErrRequestBody(err))
http.Error(w, ErrRequestBody(err).Error(), http.StatusInternalServerError)
return
}
eventBuilder := events.NewEvent().ActedUpon(connectionID).FromUser(userID).FromSystem(*h.SystemID).WithCategory("connection").WithAction("update")
connection := &models.ConnectionPayload{}
err = json.Unmarshal(bd, connection)
obj := "connection"
if err != nil {
h.log.Error(models.ErrUnmarshal(err, obj))
http.Error(w, models.ErrUnmarshal(err, obj).Error(), http.StatusInternalServerError)
return
}
updatedConnection, err := provider.UpdateConnectionById(req, connection, mux.Vars(req)["connectionId"])
if err != nil {
_err := ErrFailToSave(err, obj)
metadata := map[string]interface{}{
"error": _err,
}
event := eventBuilder.WithSeverity(events.Error).WithDescription("Error updating connection").WithMetadata(metadata).Build()
_ = provider.PersistEvent(event)
go h.config.EventBroadcaster.Publish(userID, event)
h.log.Error(_err)
http.Error(w, _err.Error(), http.StatusInternalServerError)
return
}
description := fmt.Sprintf("Connection %s updated.", updatedConnection.Name)
event := eventBuilder.WithSeverity(events.Informational).WithDescription(description).Build()
_ = provider.PersistEvent(event)
go h.config.EventBroadcaster.Publish(userID, event)
h.log.Info(description)
w.WriteHeader(http.StatusOK)
}
// swagger:route DELETE /api/integrations/connections/{connectionId} DeleteConnection idDeleteConnection
// Handle DELETE request for deleting an existing connection by connection ID
//
// Deletes existing connection
// responses:
// 200: noContentWrapper
func (h *Handler) DeleteConnection(w http.ResponseWriter, req *http.Request, _ *models.Preference, user *models.User, provider models.Provider) {
connectionID := uuid.FromStringOrNil(mux.Vars(req)["connectionId"])
userID := uuid.FromStringOrNil(user.ID)
eventBuilder := events.NewEvent().ActedUpon(connectionID).FromUser(userID).FromSystem(*h.SystemID).WithCategory("connection").WithAction("delete")
deletedConnection, err := provider.DeleteConnection(req, connectionID)
if err != nil {
obj := "connection"
_err := ErrFailToSave(err, obj)
metadata := map[string]interface{}{
"error": _err,
}
event := eventBuilder.WithSeverity(events.Error).WithDescription("Error deleting connection").WithMetadata(metadata).Build()
_ = provider.PersistEvent(event)
go h.config.EventBroadcaster.Publish(userID, event)
h.log.Error(_err)
http.Error(w, _err.Error(), http.StatusInternalServerError)
return
}
description := fmt.Sprintf("Connection %s deleted.", deletedConnection.Name)
event := eventBuilder.WithSeverity(events.Informational).WithDescription(description).Build()
_ = provider.PersistEvent(event)
go h.config.EventBroadcaster.Publish(userID, event)
h.log.Info("connection deleted successfully")
w.WriteHeader(http.StatusOK)
}