summaryrefslogtreecommitdiffstats
path: root/cmd (unfollow)
Commit message (Collapse)AuthorFilesLines
2024-02-10Adds a comment above code to handle "/" routeMatthew Lemon1-0/+4
We only want "/" to match the home route; this comment explains that.
2024-02-10Adds missing importMatthew Lemon1-1/+0
2024-02-10Have added Insert handler for Organisation modelMatthew Lemon2-13/+45
This is a straight forward wrapper around INSERT. Also added a clientError into a new helpers.go file.
2024-02-09Adds the Organisations modelMatthew Lemon1-2/+5
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.
2024-02-09Adds the database driver and opens database poolMatthew Lemon1-4/+36
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.
2024-02-09Adds flagsMatthew Lemon1-2/+7
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.
2024-02-08Added nav partialMatthew Lemon1-2/+2
Added a partial html for the navigation bar. So far it just has a link to "Home" on it.
2024-02-08Created a /organisations/list routeMatthew Lemon3-4/+35
There is also some basic CSS here. Also introduced a proper structured logger.
2024-02-08First proper use of templatesMatthew Lemon1-1/+1
2024-02-08First appearance of HTML on the home pageMatthew Lemon1-1/+33
2024-02-08Moved main to cmd/web and added routes() methodMatthew Lemon3-0/+45
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.