Skip to content

daqiancode/irisx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

irisx

extends iris

Installation

go get -u github.com/daqiancode/irisx@main

Example

import (
	"github.com/daqiancode/irisx"
	"github.com/daqiancode/irisx/jwts"
)

func setupDependencies(app *iris.Application) {
	app.RegisterDependency(func(ctx iris.Context) irisx.Context {
		return irisx.Context{Context: ctx}
	})
	app.RegisterDependency(new(service.Users))
}

func setupControllers(app *iris.Application) {
	accessTokenSetter := jwts.AccessTokenSetter(jwts.AccessTokenSetterConfig{PublicKey: config.Getenv("JWT_PUBLIC_KEY")})
	api := mvcApp.Party(config.PREFIX+"/api", accessTokenSetter)
	api.Party("/major", jwts.Require(),jwts.RBAC([]string{"USER"})).Handle(new(UserController))
}



type UserController struct {
	Ctx              irisx.Context
	Users            *service.Users
}
func (c *UserController) Get() {
	uid := c.Ctx.GetUID() // get user id from access_token
	c.Ctx.OK(c.Users.Get(uid))
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages