-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
28 lines (25 loc) · 975 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package main
import (
"fmt"
"log"
"net/http"
jwtmiddleware "github.com/auth0/go-jwt-middleware"
jwt "github.com/form3tech-oss/jwt-go"
"github.com/gorilla/mux"
)
func main() {
fmt.Println("started-service")
jwtMiddleware := jwtmiddleware.New(jwtmiddleware.Options{
ValidationKeyGetter: func(token *jwt.Token) (interface{}, error) {
return []byte(mySigningKey), nil
},
SigningMethod: jwt.SigningMethodHS256,
})
r := mux.NewRouter()
r.Handle("/upload", jwtMiddleware.Handler(http.HandlerFunc(uploadHandler))).Methods("POST", "OPTIONS")
r.Handle("/search", jwtMiddleware.Handler(http.HandlerFunc(searchHandler))).Methods("GET", "OPTIONS")
r.Handle("/signup", http.HandlerFunc(signupHandler)).Methods("POST", "OPTIONS")
r.Handle("/signin", http.HandlerFunc(signinHandler)).Methods("POST", "OPTIONS")
r.Handle("/post{id}", jwtMiddleware.Handler(http.HandlerFunc(deleteHandler))).Methods("DELETE", "OPTIONS")
log.Fatal(http.ListenAndServe(":8080", r))
}