summaryrefslogtreecommitdiffstats
path: root/cmd/web (follow)
Commit message (Collapse)AuthorAgeFilesLines
* wip: Cannot get the dynamic data to show up in templateMatthew Lemon2024-02-112-6/+19
|
* Adds an operations html templateMatthew Lemon2024-02-111-4/+17
| | | | | Does not contain any dynamic data at this point, i.e. does not actually list the operations from the database - just dummy data at this point.
* Have added a listAll handler for new operation modelMatthew Lemon2024-02-113-0/+16
| | | | | | | 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.
* Implements Latest() organisation model methodMatthew Lemon2024-02-101-11/+21
| | | | And puts the list in plain text on the home page.
* Adds the Get handler for organisation model and fixesMatthew Lemon2024-02-102-27/+46
| | | | | Also fixes the NotAuthorised response I was mistakenly getting when it should have been a 404.
* Adds the view handler for our organisation modelMatthew Lemon2024-02-102-0/+6
| | | | | | We omitted to include this earlier and it is needed for the create handler, which creates the new entity in the database and then redirects to the view handler which will show the organisation page.
* Adds a comment above code to handle "/" routeMatthew Lemon2024-02-101-0/+4
| | | | We only want "/" to match the home route; this comment explains that.
* Adds missing importMatthew Lemon2024-02-101-1/+0
|
* Have added Insert handler for Organisation modelMatthew Lemon2024-02-102-13/+45
| | | | | | This is a straight forward wrapper around INSERT. Also added a clientError into a new helpers.go file.
* Adds the Organisations modelMatthew Lemon2024-02-091-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.
* Adds the database driver and opens database poolMatthew Lemon2024-02-091-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.
* Adds flagsMatthew Lemon2024-02-091-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.
* Added nav partialMatthew Lemon2024-02-081-2/+2
| | | | | Added a partial html for the navigation bar. So far it just has a link to "Home" on it.
* Created a /organisations/list routeMatthew Lemon2024-02-083-4/+35
| | | | | | There is also some basic CSS here. Also introduced a proper structured logger.
* First proper use of templatesMatthew Lemon2024-02-081-1/+1
|
* First appearance of HTML on the home pageMatthew Lemon2024-02-081-1/+33
|
* Moved main to cmd/web and added routes() methodMatthew Lemon2024-02-083-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.