| Commit message (Collapse) | Author | Age | Files | Lines |
| |
|
|
|
|
|
|
|
| |
This is the first attempt at querying a table with a foreign key
relation and returning the result to be used in Go code. Learned quite a
bit! Including getting a null pointer error because I forgot to
initialise the sql.DB in the application structure.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
We have separation of concerns: the model is initalised and passed into
the app struct, therefore our database logic will not be tied to our
handlers.
Our model, with its methods, is nicely encapsulated. We can initialise
it and pass it to our handlers as a dependency.
We can in future create an interface to mock the OrganisationModel
object to be used in unit testing.
We can also switch databases (theoretically) but providing a -dsn
command-line flag.
|
|
|
|
|
|
|
|
| |
Adds the new -dsn flag so that the user can pass any database into the
program.
Adds a new function that wraps sql.Open() to create the connection pool,
and pings it to ensure it is alive.
|
|
|
|
|
|
|
|
|
| |
Accepts -addr for the port.
Commented out flag for dsn (database string) - not yet implemented.
See https://github.com/go-sql-driver/mysql#dsn-data-source-name for the
correct format to be used for MySQL/MariaDB.
|
|
|
|
|
|
| |
There is also some basic CSS here.
Also introduced a proper structured logger.
|
|
Started to separate out funtionality: added an application struct and
several methods (routes(), home() and a notFound() error).
At the moment, the application struct does not carry any other
configuration objects or a database pool connection - it is just there
to get the routing going.
|