Skip to content

Commit fc6bd99

Browse files
authored
Merge pull request #68 from arnested/upgrade
Upgrade dependencies
2 parents 7e73629 + 704f310 commit fc6bd99

File tree

6 files changed

+34
-25
lines changed

6 files changed

+34
-25
lines changed

.wwhrd.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,4 @@ whitelist:
55
- MIT
66
- BSD-2-Clause
77
- BSD-3-Clause
8-
9-
exceptions:
10-
- bitbucket.org/ww/goautoneg # Uses BSD license
8+
- Unlicense

go.mod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ module github.com/arnested/systemd-state
33
go 1.15
44

55
require (
6-
github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142
7-
github.com/godbus/dbus v0.0.0-20181101234600-2ff6f7ffd60f // indirect
8-
github.com/golang/gddo v0.0.0-20190312205958-5a2505f3dbf0
9-
github.com/google/go-cmp v0.2.0 // indirect
6+
github.com/coreos/go-systemd/v22 v22.1.0
7+
github.com/davecgh/go-spew v1.1.1 // indirect
8+
github.com/elnormous/contenttype v0.0.0-20210110050721-79150725153f
9+
github.com/kr/pretty v0.2.0 // indirect
1010
go.uber.org/automaxprocs v1.4.0
11+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
1112
)

go.sum

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142 h1:3jFq2xL4ZajGK4aZY8jz+DAF0FHjI51BXjjSwCzS1Dk=
2-
github.com/coreos/go-systemd v0.0.0-20181031085051-9002847aa142/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
3-
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
1+
github.com/coreos/go-systemd/v22 v22.1.0 h1:kq/SbG2BCKLkDKkjQf5OWwKWUKj1lgs3lFI4PxnR5lg=
2+
github.com/coreos/go-systemd/v22 v22.1.0/go.mod h1:xO0FLkIi5MaZafQlIrOotqXZ90ih+1atmu1JpKERPPk=
43
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5-
github.com/godbus/dbus v0.0.0-20181101234600-2ff6f7ffd60f h1:zlOR3rOlPAVvtfuxGKoghCmop5B0TRyu/ZieziZuGiM=
6-
github.com/godbus/dbus v0.0.0-20181101234600-2ff6f7ffd60f/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
7-
github.com/golang/gddo v0.0.0-20190312205958-5a2505f3dbf0 h1:CfaPdCDbZu8jSwjq0flJv2u+WreQM0KqytUQahZ6Xf4=
8-
github.com/golang/gddo v0.0.0-20190312205958-5a2505f3dbf0/go.mod h1:xEhNfoBDX1hzLm2Nf80qUvZ2sVwoMZ8d6IE2SrsQfh4=
9-
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ=
10-
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
11-
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
4+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
5+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
6+
github.com/elnormous/contenttype v0.0.0-20210110050721-79150725153f h1:juwLa2Kbp2uwOGMOagrkTYXN/5+7sbINMmIZSluH2Gc=
7+
github.com/elnormous/contenttype v0.0.0-20210110050721-79150725153f/go.mod h1:ngVcyGGU8pnn4QJ5sL4StrNgc/wmXZXy5IQSBuHOFPg=
8+
github.com/godbus/dbus/v5 v5.0.3 h1:ZqHaoEF7TBzh4jzPmqVhE/5A1z9of6orkAe5uHoAeME=
9+
github.com/godbus/dbus/v5 v5.0.3/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
1210
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
11+
github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs=
12+
github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
1313
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
1414
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
1515
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
@@ -21,7 +21,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P
2121
go.uber.org/automaxprocs v1.4.0 h1:CpDZl6aOlLhReez+8S3eEotD7Jx0Os++lemPlMULQP0=
2222
go.uber.org/automaxprocs v1.4.0/go.mod h1:/mTEdr7LvHhs0v7mjdxDreTz1OG5zdZGqgOnhWiR/+Q=
2323
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
24-
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
2524
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
25+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
26+
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
2627
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
2728
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

main.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"net/http"
77
"os"
88

9-
"github.com/golang/gddo/httputil"
9+
"github.com/elnormous/contenttype"
1010
)
1111

1212
func main() {
@@ -27,13 +27,22 @@ func main() {
2727
}
2828

2929
func handler(w http.ResponseWriter, r *http.Request) {
30-
contentType := httputil.NegotiateContentType(r, []string{"text/html", "application/json", "text/plain"}, "text/plain")
30+
supportedContentTypes := []contenttype.MediaType{
31+
contenttype.NewMediaType("text/plain"),
32+
contenttype.NewMediaType("application/json"),
33+
contenttype.NewMediaType("text/html"),
34+
}
35+
36+
contentType, _, err := contenttype.GetAcceptableMediaType(r, supportedContentTypes)
37+
if err != nil {
38+
contentType = contenttype.NewMediaType("text/plain")
39+
}
3140

3241
// Explicitly set the Content-Type header on non-HEAD requests
3342
// if the request "application/json". This is because
3443
// http.DetectContentType() is not able to detect it.
35-
if "application/json" == contentType && r.Method != http.MethodHead {
36-
w.Header().Set("Content-Type", contentType)
44+
if "application/json" == contentType.String() && r.Method != http.MethodHead {
45+
w.Header().Set("Content-Type", contentType.String())
3746
}
3847

3948
status, stateFormat := getStatusAndFormat(State())
@@ -45,7 +54,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
4554
return
4655
}
4756

48-
writeBody(w, contentType, stateFormat)
57+
writeBody(w, contentType.String(), stateFormat)
4958
}
5059

5160
func getAddr() string {

state.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package main
22

3-
import "github.com/coreos/go-systemd/dbus"
3+
import "github.com/coreos/go-systemd/v22/dbus"
44

55
// SystemdState type is the state of systemd.
66
type SystemdState struct {

state_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"testing"
55

6-
"github.com/coreos/go-systemd/dbus"
6+
"github.com/coreos/go-systemd/v22/dbus"
77
)
88

99
func makeState(s string) SystemdState {

0 commit comments

Comments
 (0)