I do not how to ask the question, but I am confused by how to manage sessions when the server is at local host.
Accessing the database direct
Without a middleware (REST), sessions are created as soon as you connect to the database. Even 2 connections from same computer gets 2 separate sessions.
Accessing via Go and localhost (127.0.0.1)
Using Golang as middleware, all connections go through 127.0.0.1 and there will be only 1 single session.
My questions are
Is there any way to pass the cookie to Go in order to create separate database sessions?
Well, i don’t kow exactly what does your application do but generally speaking separate sessions mean separate environments for your services, and that’s good. I think a common session on middleware for many services, excepting a few cases (like authentication), can be problematic from various reasons(i don’t know… what happen if that session expires… lose all endpoints?, hang or whatever, concurrency issues, return the results, etc).
General CRUD stuff. Theoretically you can access the database by using a public ip-address and automatically get the sessions you need. But what is the point with REST if the database is public?