Skip to content

nlanatta/jwt_validation

Repository files navigation

Middleware JWT validation

Validate request with JWT Run the app:

./bin/run.sh

Main example:

package main

import (
	"github.com/gorilla/mux"
	"net/http"
	"os"
)

func main() {
	server := &Server{
		port: os.Getenv("PORT"),
		publicEndpoints: []Endpoint{
			{
				Path:    "/token",
				Handler: Token,
				Methode: http.MethodPost,
			},
			{
				Path:    "/register",
				Handler: Register,
				Methode: http.MethodPost,
			},
		},
		privateEndpoints: []Endpoint{
			{
				Path:    "/user",
				Handler: GetUser,
				Methode: http.MethodGet,
			},
		},
		middlewares: []mux.MiddlewareFunc{JwtValidation()},
		publicRoot:  "/",
		privateRoot: "/api",
	}
	server.RunServer()
}

About

Validate request with JWT

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published