mirror of
https://github.com/SourceFellows/gobuch.git
synced 2024-10-22 13:57:13 +00:00
32 lines
517 B
Go
32 lines
517 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"net/http"
|
|
|
|
"golang.source-fellows.com/samples/jwt/server/jwt"
|
|
)
|
|
|
|
func handle(res http.ResponseWriter, req *http.Request) {
|
|
token, err := jwt.CreateToken()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
res.WriteHeader(http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
err = jwt.ValidateToken(token)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
res.WriteHeader(http.StatusInternalServerError)
|
|
return
|
|
}
|
|
|
|
res.Write(token)
|
|
}
|
|
|
|
func main() {
|
|
http.HandleFunc("/", handle)
|
|
http.ListenAndServe(":8080", nil)
|
|
}
|