Refactor: move templates.AuthCodeBrowserSuccessHTML to authcode (#348)

This commit is contained in:
Hidetake Iwata
2020-07-30 09:29:49 +09:00
committed by GitHub
parent dbb684f10e
commit 2cd741735e
4 changed files with 8 additions and 15 deletions

View File

@@ -1,6 +0,0 @@
// Package templates provides templates such as HTML and messages.
//
// You can preview HTML pages by running httpserver package.
// go run ./httpserver
//
package templates

View File

@@ -4,13 +4,13 @@ import (
"log"
"net/http"
"github.com/int128/kubelogin/pkg/templates"
"github.com/int128/kubelogin/pkg/usecases/authentication/authcode"
)
func main() {
http.HandleFunc("/AuthCodeBrowserSuccessHTML", func(w http.ResponseWriter, r *http.Request) {
http.HandleFunc("/BrowserSuccessHTML", func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("content-type", "text/html")
_, _ = w.Write([]byte(templates.AuthCodeBrowserSuccessHTML))
_, _ = w.Write([]byte(authcode.BrowserSuccessHTML))
})
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Header().Add("content-type", "text/html")
@@ -18,7 +18,7 @@ func main() {
<html>
<body>
<ul>
<li><a href="AuthCodeBrowserSuccessHTML">AuthCodeBrowserSuccessHTML</a></li>
<li><a href="BrowserSuccessHTML">BrowserSuccessHTML</a></li>
</ul>
</body>
</html>

View File

@@ -8,7 +8,6 @@ import (
"github.com/int128/kubelogin/pkg/adaptors/oidcclient"
"github.com/int128/kubelogin/pkg/domain/oidc"
"github.com/int128/kubelogin/pkg/domain/pkce"
"github.com/int128/kubelogin/pkg/templates"
"golang.org/x/sync/errgroup"
"golang.org/x/xerrors"
)
@@ -47,7 +46,7 @@ func (u *Browser) Do(ctx context.Context, o *BrowserOption, client oidcclient.In
PKCEParams: p,
RedirectURLHostname: o.RedirectURLHostname,
AuthRequestExtraParams: o.AuthRequestExtraParams,
LocalServerSuccessHTML: templates.AuthCodeBrowserSuccessHTML,
LocalServerSuccessHTML: BrowserSuccessHTML,
}
readyChan := make(chan string, 1)
defer close(readyChan)

View File

@@ -1,7 +1,7 @@
package templates
package authcode
// AuthCodeBrowserSuccessHTML is the success page on browser based authentication.
const AuthCodeBrowserSuccessHTML = `
// BrowserSuccessHTML is the success page on browser based authentication.
const BrowserSuccessHTML = `
<!DOCTYPE html>
<html lang="en">
<head>