about summary refs log tree commit diff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go23
1 files changed, 12 insertions, 11 deletions
diff --git a/main.go b/main.go
index a799956..a372932 100644
--- a/main.go
+++ b/main.go
@@ -10,7 +10,7 @@ import (
 	"strconv"
 )
 
-// Defining the constants used in the NFW profile
+// Defining the constants used in the NFWHandler profile
 const (
 	sigma float64 = 200
 	f0    float64 = 0.1
@@ -19,10 +19,10 @@ const (
 )
 
 type result struct {
-	NFW float64 `json:"NFW"`
+	NFW float64 `json:"NFWHandler"`
 }
 
-// The actual NFW profile
+// The actual NFWHandler profile
 // Uses the given distance to the middle of the galaxy to calculate the probability that a star is generated
 func rho(x float64, y float64, z float64) float64 {
 	r := math.Sqrt(math.Pow(x, 2) + math.Pow(y, 2) + math.Pow(z, 2))
@@ -31,7 +31,7 @@ func rho(x float64, y float64, z float64) float64 {
 	return a * b
 }
 
-// A subset of the NFW function in order to handle the 0 case
+// A subset of the NFWHandler function in order to handle the 0 case
 func phi(x float64) float64 {
 	if x == 0 {
 		return -4 * math.Pi * f0 * G * math.Pow(rS, 2)
@@ -41,10 +41,10 @@ func phi(x float64) float64 {
 	return a * b
 }
 
-// NFW is the corresponding HTTP-handler to the NFW Profile
+// NFWHandler is the corresponding HTTP-handler to the NFWHandler Profile
 // It uses the given distance to the Midpoint of the galaxy to calculate and return the probability that a star
 // is generated.
-func NFW(w http.ResponseWriter, r *http.Request) {
+func NFWHandler(w http.ResponseWriter, r *http.Request) {
 	params := r.URL.Query()
 
 	// parse the parameters
@@ -52,7 +52,7 @@ func NFW(w http.ResponseWriter, r *http.Request) {
 	y, _ := strconv.ParseFloat(params.Get("y"), 64)
 	z, _ := strconv.ParseFloat(params.Get("z"), 64)
 
-	// calculate the NFW-value
+	// calculate the NFWHandler-value
 	var returnValue result = result{rho(x, y, z)}
 	log.Print(returnValue)
 	b, err := json.Marshal(returnValue)
@@ -68,16 +68,17 @@ func NFW(w http.ResponseWriter, r *http.Request) {
 	}
 }
 
-func Index(w http.ResponseWriter, r *http.Request) {
-	log.Print(fmt.Fprintln(w, "usage: nfw.docker.localhost/NFW?x=<x>&y=<y>&z=<z>"))
+// IndexHandler handles request on the / endpoint
+func IndexHandler(w http.ResponseWriter, r *http.Request) {
+	log.Print(fmt.Fprintln(w, "usage: nfw.docker.localhost/NFWHandler?x=<x>&y=<y>&z=<z>"))
 }
 
 func main() {
 	router := mux.NewRouter()
 
 	// routes
-	router.HandleFunc("/", Index).Methods("GET")
-	router.HandleFunc("/NFW", NFW).Methods("GET")
+	router.HandleFunc("/", IndexHandler).Methods("GET")
+	router.HandleFunc("/NFWHandler", NFWHandler).Methods("GET")
 
 	log.Println("Starting the service on port localhost:8081")
 	log.Fatal(http.ListenAndServe(":8081", router))