Skip to content

Commit b33d998

Browse files
authored
Merge pull request #33 from disco07/main2
testing
2 parents 6d2acc0 + 47e7046 commit b33d998

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

main.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func JSON(w http.ResponseWriter, status int, data interface{}) error {
4242
return nil
4343
}
4444

45-
func (a apps) findAllPost(ctx context.Context) ([]*post, error) {
45+
func (a *apps) findAllPost(ctx context.Context) ([]*post, error) {
4646
query := fmt.Sprintf(`SELECT * FROM post`)
4747
rows, err := a.DB.QueryContext(ctx, query)
4848
if err != nil {
@@ -63,7 +63,7 @@ func (a apps) findAllPost(ctx context.Context) ([]*post, error) {
6363
return posts, nil
6464
}
6565

66-
func (a apps) getPosts(w http.ResponseWriter, r *http.Request) {
66+
func (a *apps) getPosts(w http.ResponseWriter, r *http.Request) {
6767
posts, err := a.findAllPost(r.Context())
6868
if err != nil {
6969
JSON(w, http.StatusBadRequest, err)
@@ -88,7 +88,7 @@ func main() {
8888
app := apps{db}
8989

9090
http.HandleFunc("/posts", app.getPosts)
91-
http.ListenAndServe(fmt.Sprintf(":%v", cfg.port), nil)
91+
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", cfg.port), nil))
9292
}
9393

9494
func open(cfg config) (*sql.DB, error) {

0 commit comments

Comments
 (0)