Skip to content

Commit 4059378

Browse files
committed
Add missing headers
1 parent 318b0a2 commit 4059378

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

frameworks/Go/indigo/src/app.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"math/rand/v2"
77
"slices"
88
"strconv"
9+
"time"
910

1011
"github.com/indigo-web/indigo/http"
1112
"github.com/indigo-web/indigo/http/mime"
@@ -39,7 +40,7 @@ func (app *App) PopulateCache(ctx context.Context) error {
3940
}
4041

4142
func (app *App) HandleJSON(request *http.Request) *http.Response {
42-
return request.Respond().JSON(&models.Message{
43+
return request.Respond().Header("Date", time.Now().Format(time.RFC1123)).Header("Server", "go").JSON(&models.Message{
4344
Message: "Hello, World!",
4445
})
4546
}
@@ -54,7 +55,7 @@ func (app *App) HandleDB(request *http.Request) *http.Response {
5455
return http.Error(request, err)
5556
}
5657

57-
return request.Respond().JSON(world)
58+
return request.Respond().Header("Date", time.Now().Format(time.RFC1123)).Header("Server", "go").JSON(world)
5859
}
5960

6061
func (app *App) HandleQuery(request *http.Request) *http.Response {
@@ -74,7 +75,7 @@ func (app *App) HandleQuery(request *http.Request) *http.Response {
7475
return http.Error(request, err)
7576
}
7677

77-
return request.Respond().JSON(&worlds)
78+
return request.Respond().Header("Date", time.Now().Format(time.RFC1123)).Header("Server", "go").JSON(&worlds)
7879
}
7980

8081
func (app *App) HandleUpdate(request *http.Request) *http.Response {
@@ -103,7 +104,7 @@ func (app *App) HandleUpdate(request *http.Request) *http.Response {
103104
return http.Error(request, err)
104105
}
105106

106-
return request.Respond().JSON(&worlds)
107+
return request.Respond().Header("Date", time.Now().Format(time.RFC1123)).Header("Server", "go").JSON(&worlds)
107108
}
108109

109110
func (app *App) HandleCachedQuery(request *http.Request) *http.Response {
@@ -118,7 +119,7 @@ func (app *App) HandleCachedQuery(request *http.Request) *http.Response {
118119
worlds[i] = app.Cache[rand.Int32N(10000)]
119120
}
120121

121-
return request.Respond().JSON(&worlds)
122+
return request.Respond().Header("Date", time.Now().Format(time.RFC1123)).Header("Server", "go").JSON(&worlds)
122123
}
123124

124125
func (app *App) HandleFortune(request *http.Request) *http.Response {
@@ -141,11 +142,11 @@ func (app *App) HandleFortune(request *http.Request) *http.Response {
141142
return 0
142143
})
143144

144-
return request.Respond().ContentType(mime.HTML).String(templates.HTMLFortunes(fortunes))
145+
return request.Respond().Header("Date", time.Now().Format(time.RFC1123)).Header("Server", "go").ContentType(mime.HTML).String(templates.HTMLFortunes(fortunes))
145146
}
146147

147148
func (app *App) HandlePlaintext(request *http.Request) *http.Response {
148-
return request.Respond().String("Hello, World!")
149+
return request.Respond().Header("Date", time.Now().Format(time.RFC1123)).Header("Server", "go").String("Hello, World!")
149150
}
150151

151152
func normalizeNumber(nString string, found bool) (int, error) {

frameworks/Go/indigo/src/main.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ func main() {
2626
DB := NewDB(pool)
2727
app := NewApp(DB)
2828

29-
err = app.PopulateCache(context.Background())
30-
if err != nil {
31-
log.Fatal(err)
32-
}
29+
// err = app.PopulateCache(context.Background())
30+
// if err != nil {
31+
// log.Fatal(err)
32+
// }
3333

3434
router := inbuilt.New()
3535

0 commit comments

Comments
 (0)