Skip to content

Commit

Permalink
handle all requests the same, remove chi
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisDeFouRire committed Dec 15, 2023
1 parent a7e3843 commit ac36de1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ module github.com/chrisDeFouRire/subauth

go 1.21.3

require (
github.com/go-chi/chi/v5 v5.0.10
github.com/golang-jwt/jwt/v5 v5.2.0
)
require github.com/golang-jwt/jwt/v5 v5.2.0
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
github.com/go-chi/chi/v5 v5.0.10 h1:rLz5avzKpjqxrYwXNfmjkrYYXOyLJd37pz53UFHC6vk=
github.com/go-chi/chi/v5 v5.0.10/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw=
github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
9 changes: 4 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"os"
"strings"

"github.com/go-chi/chi/v5"
"github.com/golang-jwt/jwt/v5"
)

Expand Down Expand Up @@ -72,9 +71,9 @@ func init() {
}

func main() {
r := chi.NewRouter()

r.Get("/", func(w http.ResponseWriter, r *http.Request) {
// no matter what the Method or URL is, we always check the Authorization header
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
authorization := r.Header.Get("Authorization")
token, err := parseBearerToken(authorization)
if err != nil {
Expand All @@ -94,9 +93,9 @@ func main() {
w.WriteHeader(http.StatusNoContent)
})

err := http.ListenAndServe(":8080", r)
log.Println("Server started")
err := http.ListenAndServe(":8080", nil)
if err != nil {
panic(err)
}
log.Println("Server started")
}

0 comments on commit ac36de1

Please sign in to comment.