waistline
waistline copied to clipboard
Documentation hole or incomplete new upcoming feature?
In the screenshot above you can see where there is a field for a service address. Is this for self-hosting a back end for this app? If so, is there any documentation yet at how to create such a service address?
You are right, there is almost no documentation for this feature. It was added in #623 and allows users to send the data from the app to their own self-hosted backend service. Maybe the author of that pull request can give you more information or even provide an example implementation of the server side backend logic.
Thank you for tagging that feature; I was able to get this working for a demo which I will document below.
- Using Go; setup a quick Server with a Post Route
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
)
func main() {
http.HandleFunc("/", requestBodyHandler)
log.Fatal(http.ListenAndServe(":8085", nil))
}
func requestBodyHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != "POST" {
w.WriteHeader(http.StatusMethodNotAllowed)
fmt.Fprint(w, "Only POST requests are allowed")
return
}
body, err := ioutil.ReadAll(r.Body)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
fmt.Fprint(w, "Error reading request body")
return
}
defer r.Body.Close()
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Request Body: %s", body)
fmt.Printf("Request Body: %s\n", body)
}
- setup server behind Nginx Proxy Manager to allow a simple reverse proxy with https authorizations
- Define this new nginx proxy address in the app in the developer field
- If you look at the logs from the server you will see the posts for any manipulation with nutrition sent back to the server.
As seen below
Although I can now see how this feature is working; I would be curious how @Kroseida had imagined this being used? In my short testing I see that the HTTP POST request occurs everytime the nutrition data is accessed which means it sends even when switching between the Diary and Statistics tabs/windows with no data entry. Depending on how the post requests are consumed I imagine subsequent duplications of unchanged data could be ignored by the BE server.
Initially I thought this functionality might allow for export of both nutrition data stored per day (as it does) but I also thought it might export weigh in data which it does not natively though I imagine that can be a quick addition if desired.