Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up autocert https #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# lastwin
[lastwin.info](http://lastwin.info)
[lastwin.info](https://lastwin.info)
4 changes: 2 additions & 2 deletions get_teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

var (
cfbTeamsURL = "http://www.espn.com/college-football/teams"
nflTeamsURL = "http://www.espn.com/nfl/teams"
cfbTeamsURL = "https://www.espn.com/college-football/teams"
nflTeamsURL = "https://www.espn.com/nfl/teams"
)

// Team is a struct storing team name and id
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ go 1.12
require (
github.com/gorilla/mux v1.7.3
github.com/sahilm/fuzzy v0.1.0
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f // indirect
)
11 changes: 11 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,14 @@ github.com/gorilla/mux v1.7.3 h1:gnP5JzjVOuiZD07fKKToCAOjS0yOpj/qPETTXCCS6hw=
github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI=
github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f h1:OeJjE6G4dgCY4PIXvIRQbE8+RX+uXZyGhUy/ksMGJoc=
golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 h1:CIJ76btIcR3eFI5EgSo6k1qKw9KJexJuRLI9G7Hp5wE=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
24 changes: 17 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"time"

"github.com/gorilla/mux"
"golang.org/x/crypto/acme/autocert"
)

var (
Expand All @@ -23,14 +24,14 @@ var (

urls = map[string]map[string]string{
"cfb": {
"query": "http://www.espn.com/college-football/team/schedule/_/id/%s/season/%s",
"espn": "http://www.espn.com/college-football/team/_/id/%s",
"img": "http://a.espncdn.com/combiner/i?img=/i/teamlogos/ncaa/500/%s.png",
"query": "https://www.espn.com/college-football/team/schedule/_/id/%s/season/%s",
"espn": "https://www.espn.com/college-football/team/_/id/%s",
"img": "https://a.espncdn.com/combiner/i?img=/i/teamlogos/ncaa/500/%s.png",
},
"nfl": {
"query": "https://www.espn.com/nfl/team/schedule/_/name/%s/season/%s",
"espn": "http://www.espn.com/nfl/team/_/id/%s",
"img": "http://a.espncdn.com/combiner/i?img=/i/teamlogos/nfl/500/%s.png",
"espn": "https://www.espn.com/nfl/team/_/id/%s",
"img": "https://a.espncdn.com/combiner/i?img=/i/teamlogos/nfl/500/%s.png",
},
}
)
Expand Down Expand Up @@ -159,6 +160,15 @@ func main() {
fileServer := Gzip(http.FileServer(http.Dir("static/")))
r.PathPrefix("/static/").Handler(http.StripPrefix("/static/", fileServer))

log.Printf("Starting server on port %s", port)
log.Fatal(http.ListenAndServe(":"+port, r))
m := &autocert.Manager{
Cache: autocert.DirCache("."),
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist("www.lastwin.info", "lastwin.info"),
}
s := &http.Server{
Addr: ":https",
TLSConfig: m.TLSConfig(),
Handler: r,
}
log.Fatal(s.ListenAndServeTLS("", ""))
}
2 changes: 1 addition & 1 deletion tmpl/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>&#127944;</text></svg>">
<link rel="icon" href="data:image/svg+xml,<svg xmlns=%22https://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>&#127944;</text></svg>">

<!-- Styles -->
<link rel="stylesheet" href="../static/bootstrap.min.css">
Expand Down
2 changes: 1 addition & 1 deletion tmpl/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
When did your football team last win?
{{ end }}
{{ define "image" }}
http://lastwin.info/static/football.png
https://lastwin.info/static/football.png
{{ end }}
{{ define "content" }}
<!--
Expand Down