differ between oauth2 and oidc relaying party

This commit is contained in:
Livio Amstutz 2020-09-16 10:51:33 +02:00
parent d97df8a9b2
commit 693ce1a07a
6 changed files with 128 additions and 219 deletions

View file

@ -1,9 +1,11 @@
package utils
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
"strings"
@ -79,3 +81,18 @@ func URLEncodeResponse(resp interface{}, encoder Encoder) (string, error) {
v := url.Values(values)
return v.Encode(), nil
}
func StartServer(ctx context.Context, port string) {
server := &http.Server{Addr: port}
go func() {
if err := server.ListenAndServe(); err != http.ErrServerClosed {
log.Fatalf("ListenAndServe(): %v", err)
}
}()
go func() {
<-ctx.Done()
err := server.Shutdown(ctx)
log.Fatalf("Shutdown(): %v", err)
}()
}