Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
8f1654a3cf | |||
6851467d46 | |||
aceb53efe9 | |||
0be0c38fb1 | |||
d946069f6a | |||
cdbfe64f5c |
14
CHANGELOG.md
14
CHANGELOG.md
@ -1,3 +1,17 @@
|
|||||||
|
## [1.0.24](http://gitea.gitea.svc.cluster.local:3000/djpbessems/ContainerImage.SpamasaurusRex/compare/v1.0.23...v1.0.24) (2024-03-11)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Refactor to use filesystem storage instead of cookies ([aceb53e](http://gitea.gitea.svc.cluster.local:3000/djpbessems/ContainerImage.SpamasaurusRex/commit/aceb53efe914ddc4ffd9c9ff3bad3917c138fd69))
|
||||||
|
|
||||||
|
## [1.0.23](http://gitea.gitea.svc.cluster.local:3000/djpbessems/ContainerImage.SpamasaurusRex/compare/v1.0.22...v1.0.23) (2024-03-11)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* Register type with gob interface ([cdbfe64](http://gitea.gitea.svc.cluster.local:3000/djpbessems/ContainerImage.SpamasaurusRex/commit/cdbfe64f5c04ac7d19ae14ca9ff826d2990dc065))
|
||||||
|
|
||||||
## [1.0.22](http://gitea.gitea.svc.cluster.local:3000/djpbessems/ContainerImage.SpamasaurusRex/compare/v1.0.21...v1.0.22) (2024-03-11)
|
## [1.0.22](http://gitea.gitea.svc.cluster.local:3000/djpbessems/ContainerImage.SpamasaurusRex/compare/v1.0.21...v1.0.22) (2024-03-11)
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"encoding/gob"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@ -27,7 +28,39 @@ var config = oauth2.Config{
|
|||||||
Scopes: []string{"email", "openid", "profile", "user.read"},
|
Scopes: []string{"email", "openid", "profile", "user.read"},
|
||||||
}
|
}
|
||||||
|
|
||||||
var sessionStore = sessions.NewCookieStore([]byte("xDDBjhYwyndZty3exGNq2ahE8wHRCR4DfdCJCSoWXAYncfWw2UQDH63QcJ9CkrGx"))
|
var sessionStore = sessions.NewFilesystemStore("", []byte("xDDBjhYwyndZty3exGNq2ahE8wHRCR4DfdCJCSoWXAYncfWw2UQDH63QcJ9CkrGx"))
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// Register the oauth2.Token type with gob
|
||||||
|
gob.Register(&oauth2.Token{})
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
r := mux.NewRouter()
|
||||||
|
|
||||||
|
r.HandleFunc("/", rootHandler)
|
||||||
|
r.HandleFunc("/health", healthHandler)
|
||||||
|
r.HandleFunc("/callback", callbackHandler)
|
||||||
|
r.HandleFunc("/readiness", readinessHandler)
|
||||||
|
|
||||||
|
srv := &http.Server{
|
||||||
|
Handler: r,
|
||||||
|
Addr: ":8080",
|
||||||
|
ReadTimeout: 10 * time.Second,
|
||||||
|
WriteTimeout: 10 * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start Server
|
||||||
|
go func() {
|
||||||
|
log.Println("Starting Server")
|
||||||
|
if err := srv.ListenAndServe(); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Graceful Shutdown
|
||||||
|
waitForShutdown(srv)
|
||||||
|
}
|
||||||
|
|
||||||
func rootHandler(w http.ResponseWriter, r *http.Request) {
|
func rootHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
session, err := sessionStore.Get(r, "spamasaurusRex")
|
session, err := sessionStore.Get(r, "spamasaurusRex")
|
||||||
@ -87,33 +120,6 @@ func readinessHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
|
||||||
r := mux.NewRouter()
|
|
||||||
|
|
||||||
r.HandleFunc("/", rootHandler)
|
|
||||||
r.HandleFunc("/health", healthHandler)
|
|
||||||
r.HandleFunc("/callback", callbackHandler)
|
|
||||||
r.HandleFunc("/readiness", readinessHandler)
|
|
||||||
|
|
||||||
srv := &http.Server{
|
|
||||||
Handler: r,
|
|
||||||
Addr: ":8080",
|
|
||||||
ReadTimeout: 10 * time.Second,
|
|
||||||
WriteTimeout: 10 * time.Second,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start Server
|
|
||||||
go func() {
|
|
||||||
log.Println("Starting Server")
|
|
||||||
if err := srv.ListenAndServe(); err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
|
|
||||||
// Graceful Shutdown
|
|
||||||
waitForShutdown(srv)
|
|
||||||
}
|
|
||||||
|
|
||||||
func waitForShutdown(srv *http.Server) {
|
func waitForShutdown(srv *http.Server) {
|
||||||
interruptChan := make(chan os.Signal, 1)
|
interruptChan := make(chan os.Signal, 1)
|
||||||
signal.Notify(interruptChan, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
signal.Notify(interruptChan, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
||||||
|
Reference in New Issue
Block a user