fix: Register type with gob interface
This commit is contained in:
parent
2b61ef233d
commit
cdbfe64f5c
@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
@ -29,6 +30,38 @@ var config = oauth2.Config{
|
||||
|
||||
var sessionStore = sessions.NewCookieStore([]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) {
|
||||
session, err := sessionStore.Get(r, "spamasaurusRex")
|
||||
if err != nil {
|
||||
@ -87,33 +120,6 @@ func readinessHandler(w http.ResponseWriter, r *http.Request) {
|
||||
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) {
|
||||
interruptChan := make(chan os.Signal, 1)
|
||||
signal.Notify(interruptChan, os.Interrupt, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
Loading…
Reference in New Issue
Block a user