Untested implementation of login and renew endpoints
This commit is contained in:
parent
f484674524
commit
d023bb0adf
2 changed files with 65 additions and 4 deletions
|
@ -9,6 +9,8 @@ import (
|
|||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
|
||||
jwtware "github.com/gofiber/contrib/jwt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -33,14 +35,23 @@ func main() {
|
|||
// This will likely be replaced by an embedded filesystem in the future
|
||||
server.Static("/", "./static")
|
||||
|
||||
// Register our handlers
|
||||
// Register our unprotected routes
|
||||
server.Post("/api/register", gs.Register)
|
||||
server.Delete("/api/userdelete", gs.UserDelete) // Perhaps just use POST to avoid headaches
|
||||
|
||||
// Register handlers for example button count
|
||||
server.Get("/api/button", gs.GetButtonCount)
|
||||
server.Post("/api/button", gs.IncrementButtonCount)
|
||||
|
||||
server.Post("/api/login", gs.Login)
|
||||
|
||||
// Every route from here on will require a valid JWT
|
||||
server.Use(jwtware.New(jwtware.Config{
|
||||
SigningKey: jwtware.SigningKey{Key: []byte("secret")},
|
||||
}))
|
||||
|
||||
server.Post("/api/loginrenew", gs.LoginRenew)
|
||||
server.Delete("/api/userdelete", gs.UserDelete) // Perhaps just use POST to avoid headaches
|
||||
|
||||
// Announce the port we are listening on and start the server
|
||||
err = server.Listen(fmt.Sprintf(":%d", conf.Port))
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue