"github.com/clerkinc/clerk-sdk-go/clerk"
client, _ := clerk.NewClient("CLERK_API_KEY")
mux := http.NewServeMux()
injectActiveSession := clerk.WithSession(client)
mux.Handle("/hello", injectActiveSession(helloUserHandler(client)))
http.ListenAndServe(":8080", mux)
func helloUserHandler(client clerk.Client) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
sess, ok := ctx.Value(clerk.ActiveSession).(*clerk.Session)
w.WriteHeader(http.StatusUnauthorized)
w.Write([]byte("Unauthorized"))
// Optionally get the user, and say welcome!
user, err := client.Users().Read(sess.UserID)
w.Write([]byte("Welcome " + *user.FirstName))