tb/main #1
Loading…
Reference in a new issue
No description provided.
Delete branch "tb/main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This pull request connects all sections of the application and resolves issues with internal package imports. Naming is not finalized and still slightly messy, but the test function can successfully add an entry to the database.
Additionally, documentation is added on deleting and creating the database in the readme.
@ -0,0 +44,4 @@
router.Run("localhost:8080")
}
func (s *ApiService) runTest(c *gin.Context) {
what is the goal of this
api
folder, is it to:a. bind API routes to functions
or b. parse out the parameters of our queries to then pass to the called service?
I think it would be fine to have both of these in the same folder but it might get to be a bit messy to have both of them in one place. Ideally a would live somewhere related to our
swagger.yml
file but that's just in the directory above us right now. Maybe we can move the swagger file into this folder, then takerunTest
(or its future non test equivalents) and create a new folder to host them. For Kotlin projects that I have worked on generally gets acontrollers
folder but I'm open to other names if you can thing of something that makes more sense to you@ -0,0 +48,4 @@
queryParam := c.Param("id")
log.Debug("Test was successful.")
err := s.db.Insert(c, database.ProductsTable, &database.Product{System: "upc", Barcode: "fubar", Created_at: time.Now()})
We shouldnt really be making DB calls here generally best practices would be to mak some function in our database folder that for example is called
createProduct
that we would just call with ourSystem
, andBarcode
value. Then we would also want to have thatdatabase::createProduct
call done within ourservices
folder (to keep a separation of our network layer and our business logic) but that ones not as big of a deal because this is just a test function that doesnt really have a defined goal in mind@ -0,0 +51,4 @@
err := s.db.Insert(c, database.ProductsTable, &database.Product{System: "upc", Barcode: "fubar", Created_at: time.Now()})
if err != nil {
// TODO: Figure out correct status code.
c.JSON(http.StatusInternalServerError, gin.H{"message": "Failed to insert item to product table", "error": err.Error()})
c.JSON I believe pipes out the passed data as a stringify value on whatever network socket the gin context has but doesnt close that connection so when we get an error we end up getting something roughly like
error: xyz... success xyz...
we want to close that connection and return early before we get to the success portion of this methodView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.