@@ -17,7 +17,6 @@ import (
1717 "github.com/function61/gokit/net/http/httputils"
1818 "github.com/function61/gokit/os/osutil"
1919 "github.com/function61/id/pkg/httpauth"
20- "github.com/gorilla/mux"
2120 "gopkg.in/square/go-jose.v2"
2221)
2322
@@ -27,7 +26,7 @@ var templateFiles embed.FS
2726var templates , _ = template .ParseFS (templateFiles , "templates/*.html" )
2827
2928func newHttpHandler () (http.Handler , error ) {
30- router := mux . NewRouter ()
29+ router := http . NewServeMux ()
3130
3231 signer , signerPublicKey , err := loadSignerAndPublicKey ()
3332 if err != nil {
@@ -46,7 +45,7 @@ func newHttpHandler() (http.Handler, error) {
4645
4746 userRegistry := newUserRegistry ()
4847
49- router .HandleFunc ("/id" , func (w http.ResponseWriter , r * http.Request ) {
48+ router .HandleFunc ("GET /id" , func (w http.ResponseWriter , r * http.Request ) {
5049 nextValidated , _ , err := getValidatedNext (r , redirectAllowList )
5150 if err != nil {
5251 http .Error (w , err .Error (), http .StatusBadRequest )
@@ -66,9 +65,9 @@ func newHttpHandler() (http.Handler, error) {
6665 }); err != nil {
6766 panic (err )
6867 }
69- }). Methods ( http . MethodGet )
68+ })
7069
71- router .HandleFunc ("/id" , func (w http.ResponseWriter , r * http.Request ) {
70+ router .HandleFunc ("POST /id" , func (w http.ResponseWriter , r * http.Request ) {
7271 nextValidated , audience , err := getValidatedNext (r , redirectAllowList )
7372 if err != nil {
7473 http .Error (w , err .Error (), http .StatusBadRequest )
@@ -110,9 +109,9 @@ func newHttpHandler() (http.Handler, error) {
110109
111110 httputils .NoCacheHeaders (w )
112111 http .Redirect (w , r , nextValidated .String (), http .StatusFound )
113- }). Methods ( http . MethodPost )
112+ })
114113
115- router .HandleFunc ("/id/profile" , func (w http.ResponseWriter , r * http.Request ) {
114+ router .HandleFunc ("GET /id/profile" , func (w http.ResponseWriter , r * http.Request ) {
116115 auth , err := authenticator .Authenticate (r )
117116 if err != nil {
118117 http .Error (w , err .Error (), http .StatusForbidden )
@@ -129,15 +128,15 @@ func newHttpHandler() (http.Handler, error) {
129128 _ = jsonfile .Marshal (w , & user )
130129 })
131130
132- router .HandleFunc ("/id/logout" , func (w http.ResponseWriter , r * http.Request ) {
131+ router .HandleFunc ("GET /id/logout" , func (w http.ResponseWriter , r * http.Request ) {
133132 httputils .NoCacheHeaders (w )
134133
135134 http .SetCookie (w , httpauth .DeleteLoginCookie ())
136135
137136 fmt .Fprintln (w , "You have been logged out." )
138137 })
139138
140- router .HandleFunc ("/id/.well-known/jwks.json" , func (w http.ResponseWriter , r * http.Request ) {
139+ router .HandleFunc ("GET /id/.well-known/jwks.json" , func (w http.ResponseWriter , r * http.Request ) {
141140 // https://tools.ietf.org/html/rfc7517
142141 w .Header ().Set ("Content-Type" , "application/jwk-set+json" )
143142 _ , _ = w .Write (signerPubKeySetJson )
0 commit comments