-
Notifications
You must be signed in to change notification settings - Fork 6
/
configuration.go
32 lines (26 loc) · 1003 Bytes
/
configuration.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
package web
import (
"net/http"
"github.com/yaptide/app/config"
"github.com/yaptide/app/web/server"
"github.com/yaptide/app/web/util"
"github.com/yaptide/converter/setup/detector"
"github.com/yaptide/converter/setup/material"
)
type getConfigurationHandler struct {
*server.Context
*config.Config
}
func (h *getConfigurationHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
var response struct {
PredefinedMaterials []material.PredefinedMaterialRecord `json:"predefinedMaterials"`
Isotopes []material.IsotopeRecord `json:"isotopes"`
ParticleTypes []detector.PredefinedParticleRecord `json:"particles"`
ScoringTypes []detector.ScoringTypeRecord `json:"scoringTypes"`
}
response.PredefinedMaterials = material.PredefinedMaterials()
response.Isotopes = material.Isotopes()
response.ParticleTypes = detector.ParticleTypes()
response.ScoringTypes = detector.ScoringTypes()
util.WriteJSONResponse(w, http.StatusOK, response)
}