摘要:
Processing forms We’re going to add an HTML form for creating new snippets. The form will look a bit like this: The high-level flow for processing thi 阅读全文
摘要:
How middleware works In fact, we’re actually already using some middleware in our application — the http.StripPrefix() function from serving static fi 阅读全文
摘要:
Displaying dynamic data func (app *application) snippetView(w http.ResponseWriter, r *http.Request) { id, err := strconv.Atoi(r.PathValue("id")) if er 阅读全文
摘要:
Creating a database connection pool // The sql.Open() function initializes a new sql.DB object, which is essentially a // pool of database connections 阅读全文
摘要:
Web application basics The first thing we need is a handler. If you’ve previously built web applications using a MVC pattern, you can think of handler 阅读全文
摘要:
These are common programming practices that, while not necessarily wrong, often lead to less efficient, less readable, and less maintainable code. By 阅读全文
摘要:
• The Mock Object pattern The Mock Object pattern provides three features: 1.Isolation: Mocks isolate the unit of code being tested, ensuring that tes 阅读全文