Using Mithril js as frontend, Golang as backend + MySQL

(Connel Evalsam Asikong) #1

I know little of both Mithril and Golang.

For now I want to mix both together, tried something tho
But I’m a little confused about routing.

How will the routing be done?

Please I need your help.

(Lutz Horn) #2

Mithril is a client side framework that can make XHR requests to a server. This server could be written in Go.

What do you mean by “routing”? Do you refer to routing as understood by Mithril? This has nothing to do with Go. Or do you mean routing as done by ServerMux? This would be a way to implement the Go backend for the XHR requests made by Mithril.

(Connel Evalsam Asikong) #3

Thanks for your reply.

I mean as done by ServerMux

I will be moving from page to page and maybe carrying data with me.

For example
I log in with my details, the next page loads with more details etc.

(Lutz Horn) #4

You are confusing the way a SPA (Single Page Application) as implemented using Mithril works with the routing of HTTP requests to methods in a backend service. The navigation of inside the SPA is completely independet from the backend, you can write a SPA with **no backend at all.

Only if the SPA needs to write or read data to or from the backend you do need a backend that handles XHR HTTP requests.

Try to write a simple Mithril application that does not require a backend. Then write a simple Go HTTP server that serves some HTTP requests. Only after you understand how both work, try to combine them.

(Connel Evalsam Asikong) #5

I’ve done that.

Now would like to understand how to combine both