diff options
author | Emile <hanemile@protonmail.com> | 2019-02-28 18:31:23 +0100 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-02-28 18:31:23 +0100 |
commit | 524dd2494901fd3c1b6a33448cbe97069bd6884e (patch) | |
tree | a206bfc24298ab1b27f19609baee85413f50c594 | |
parent | 21791d06e31f9e5915fe71d7b20b6403af1b512f (diff) |
renamed the function handling requests on /NFW from NFW to NFWHandler
-rw-r--r-- | main.go | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/main.go b/main.go index 677f405..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) @@ -70,7 +70,7 @@ func NFW(w http.ResponseWriter, r *http.Request) { // IndexHandler handles request on the / endpoint func IndexHandler(w http.ResponseWriter, r *http.Request) { - log.Print(fmt.Fprintln(w, "usage: nfw.docker.localhost/NFW?x=<x>&y=<y>&z=<z>")) + log.Print(fmt.Fprintln(w, "usage: nfw.docker.localhost/NFWHandler?x=<x>&y=<y>&z=<z>")) } func main() { @@ -78,7 +78,7 @@ func main() { // routes router.HandleFunc("/", IndexHandler).Methods("GET") - router.HandleFunc("/NFW", NFW).Methods("GET") + router.HandleFunc("/NFWHandler", NFWHandler).Methods("GET") log.Println("Starting the service on port localhost:8081") log.Fatal(http.ListenAndServe(":8081", router)) |