Giter Site home page Giter Site logo

tengxiaoyang / irisadminapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from snowlyg/iris-admin

0.0 0.0 0.0 468.89 MB

iris 框架的后台api项目

Home Page: https://github.com/snowlyg/IrisAdminApi

License: Apache License 2.0

Go 45.43% JavaScript 25.73% HTML 0.34% Vue 24.48% SCSS 4.02%

irisadminapi's Introduction

IrisAdmin

Code Coverage Go Report Card GoDoc Licenses

简单项目仅供学习,欢迎指点!

IRIS V12 中文文档

Iris-go 学习交流 QQ 群 :676717248

Iris-go

If you don't have a QQ account, you can into the iris-go-tenancy/community .

Gitter

iris 学习记录分享

1.Iris-go 项目登陆 API 构建细节实现过程

2.iris + casbin 从陌生到学会使用的过程


简单使用

package main

import (
	"github.com/snowlyg/iris-admin/server/web"
)

func main() {
	webServer := web.Init()
	webServer.Run()
}

启动项目

  • 第一次启动项目后,会自动生成 config.yamlrbac_model.conf 两个配置文件
go run main.go

添加模块

  • 框架默认内置了v1 版本的基础认证模块
  • 可以使用 AddModule() 增加其他 admin模块
package main

import (
  	"github.com/snowlyg/iris-admin/server/web"
  "github.com/kataras/iris/v12"
	"github.com/snowlyg/iris-admin/middleware"
	"github.com/snowlyg/iris-admin/server/module"
)

// Party admin模块
func Party() module.WebModule {
  handler := func(admin iris.Party) {
    // 中间件
    admin.Use(middleware.InitCheck(), middleware.JwtHandler(), middleware.OperationRecord(), middleware.Casbin())
		admin.Get("/", GetAllAdmins).Name = "admin列表"
	}
	return module.NewModule("/admins", handler)
}

func GetAllAdmins(ctx iris.Context) {
  // 处理业务逻辑
  // ... 
	ctx.JSON(g.Response{Code: g.NoErr.Code, Data: list, Msg: g.NoErr.Msg})
}

func main() {
	webServer := web.Init()
  webServer.AddModule(Party())
	webServer.Run()
}

配合前端使用

  • 编译前端页面到 admim 目录
package main

import (
	"github.com/kataras/iris/v12"
	"github.com/snowlyg/iris-admin/server/web"
)

func main() {
	webServer := web.Init()
	webServer.AddStatic("/", iris.Dir("./dist"), iris.DirOptions{
		IndexName: "index.html",
		SPA:       true,
	})
	webServer.Run()
}

简单用例

单元测试和接口文档[待更新]

感谢

JetBrains 对本项目的支持。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.