diff --git a/main.go b/main.go
index ea49ae9..d70514f 100644
--- a/main.go
+++ b/main.go
@@ -22,8 +22,11 @@ type WordData struct {
var words WordData
-// Fixed symbol alphabet
-const symbolAlphabet = "!@#$%^&*()-+',?"
+// Symbol alphabets
+const (
+ fullSymbolAlphabet = "!@#$%^&*()-+',?"
+ reducedSymbolAlphabet = "@#!"
+)
type PageData struct {
// Form values
@@ -31,7 +34,8 @@ type PageData struct {
MinLen int
MaxLen int
NumLen int
- SymbolCount int // symbols per separator
+ SymbolCount int // symbols per separator
+ SymbolSet string // "full" or "reduced"
RandCaps string
// Stats
@@ -47,58 +51,6 @@ type PageData struct {
GeneratedPhrases []string
}
-// commonLogMiddleware logs requests in Apache/Nginx "Common Log Format"
-func commonLogMiddleware(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
-
- // Wrap ResponseWriter so we can capture status/size
- lrw := &loggingResponseWriter{ResponseWriter: w, status: 200}
-
- start := time.Now()
- next.ServeHTTP(lrw, r)
- duration := time.Since(start)
-
- // Determine client IP
- ip := r.RemoteAddr
- if xf := r.Header.Get("X-Forwarded-For"); xf != "" {
- ip = xf
- }
-
- // Common Log Format:
- // 127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /path HTTP/1.1" 200 2326
- log.Printf(`%s - - [%s] "%s %s %s" %d %d "%s" "%s" %v`,
- ip,
- time.Now().Format("02/Jan/2006:15:04:05 -0700"),
- r.Method,
- r.RequestURI,
- r.Proto,
- lrw.status,
- lrw.bytes,
- r.Referer(),
- r.UserAgent(),
- duration,
- )
- })
-}
-
-// loggingResponseWriter allows us to capture status code & bytes written
-type loggingResponseWriter struct {
- http.ResponseWriter
- status int
- bytes int
-}
-
-func (lrw *loggingResponseWriter) WriteHeader(code int) {
- lrw.status = code
- lrw.ResponseWriter.WriteHeader(code)
-}
-
-func (lrw *loggingResponseWriter) Write(b []byte) (int, error) {
- n, err := lrw.ResponseWriter.Write(b)
- lrw.bytes += n
- return n, err
-}
-
// Single-file HTML template
var pageTmpl = template.Must(template.New("page").Parse(`
@@ -150,6 +102,17 @@ var pageTmpl = template.Must(template.New("page").Parse(`
+
+
+
+