zoukankan      html  css  js  c++  java
  • Beego没gin配置静态页面方便

    上代码

    腾讯这个例子还是很值得学习的,不轻有东西,单也不重到看着都蒙圈的样子。

    https://github.com/Tencent/bk-cmdb/blob/master/src/web_server/service/service.go

    Beego没gin配置静态页面方便

    下面是gin的静态页面承载配置。

     ws.Static("/static", s.Config.Site.HtmlRoot)
     ws.LoadHTMLFiles(s.Config.Site.HtmlRoot + "/index.html")

    简单吧。

    func (s *Service) WebService() *gin.Engine {
        ws := gin.Default()
    
        ws.Use(sessions.Sessions(s.Config.Session.Name, s.Session))
        ws.Use(middleware.ValidLogin(*s.Config, s.Discovery()))
        middleware.Engine = s.Engine
    
        ws.Static("/static", s.Config.Site.HtmlRoot)
        ws.LoadHTMLFiles(s.Config.Site.HtmlRoot + "/index.html")
    
        ws.POST("/hosts/import", s.ImportHost)
        ws.POST("/hosts/export", s.ExportHost)
        ws.POST("/importtemplate/:bk_obj_id", s.BuildDownLoadExcelTemplate)
        ws.POST("/insts/owner/:bk_supplier_account/object/:bk_obj_id/import", s.ImportInst)
        ws.POST("/insts/owner/:bk_supplier_account/object/:bk_obj_id/export", s.ExportInst)
        ws.POST("/logout", s.LogOutUser)
        ws.POST("/object/owner/:bk_supplier_account/object/:bk_obj_id/import", s.ImportObject)
        ws.POST("/object/owner/:bk_supplier_account/object/:bk_obj_id/export", s.ExportObject)
        ws.GET("/user/list", s.GetUserList)
        ws.GET("/user/language/:language", s.UpdateUserLanguage)
        ws.GET("/userinfo", s.UserInfo)
        ws.PUT("/user/current/supplier/:id", s.UpdateSupplier)
    
        ws.GET("/healthz", s.Healthz)
        ws.GET("/", s.Index)
        return ws
    }
  • 相关阅读:
    如何在delphi里面控制Edit只能输入数字
    ShellExecute函数
    GetSystemMenu 获取系统菜单
    StringReplace 函数
    delphi 字符串查找
    Pos 函数
    Copy 函数
    css笔记
    HTML5笔记
    node.js nodejs supvisor模块
  • 原文地址:https://www.cnblogs.com/landv/p/11078500.html
Copyright © 2011-2022 走看看