#Help with front implementation
11 messages · Page 1 of 1 (latest)
Nono of course, I meant what’s the good practice for my frontend to interact with my backend
oh i gotcha.
generally my flow is, when the user goes to a new page, it should await an asynchronous function that makes an api call to get whatever data it needs to populate that page
Like would this be valid?
func main() {
mux := http.NewServeMux()
mux.HandleFunc("/login", loginHandler)
http.ListenAndServe(":8080", mux)
}
func loginHandler(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "templates/login.html")
}
I believe that would be okay yes. u can also serve a whole filesystem which is fairly common for using frameworks
I understand how to do it inside js, but no how to tell Go to leave to a html file in certain cases
like to go to a new page?
Oh ok, thanks, I’ll search it
Like in the example “for /login leave it index.html”
I think that'd be fine. but hopefully someone else can give feedback as well. in general: do it as simply as possible for right now and only add complexity when u feel it's necessary.
Okok thank you!