问题标签 [go-iris]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
go - 如何在 Iris 中使用虚拟主机?
我想知道为什么以下内容不适用于 Iris (v6.2.0):
我已在我的主机配置中将 example.com 指向 localhost。访问localhost:3000
确实给了我“来自其他地方的你好”,但访问example.com:3000
给了我 Iris 的 404 页面。
go - 虹膜错误 - 未解决的“获取”
这是我的代码
我有“go get -u github.com/kataras/iris/iris”这就是我得到的,我一直在生存,但仍然无法解决这个问题。
./IRIS.go:6: undefined: iris.Get
./IRIS.go:9: undefined: iris.Listen
这是我第一次尝试这个框架,我从页面https://docs.iris-go.com/开始 我虽然这很容易,但实际上并不容易,我只能安装 iris,这是我第一次更糟糕的你好世界
我正在使用 Intellij Idea 作为我的 IDE
请帮我。谢谢
postgresql - getsockopt:连接超时
我将我的项目从 python tornado 重写为 go(使用 iris 框架)。基本功能测试正常。当我在高并发下测试时。应用程序总是停止一段时间然后出现错误:
6543 端口是与 pgbouncer 一起使用的 postgresql 端口……pgbouncer 和 postgresl 进程运行正常。
另外,我发现 memcache 连接有时会超时(memcache 进程仍在工作)。
发生这种情况是因为连接太多吗?或者一些连接没有按时关闭?我怎样才能避免这个问题?
heroku - 为什么我的 Go Iris 应用无法部署到 Heroku?
我有非常简单的带有 Iris 的 Go 应用程序,我正在尝试将其部署到 Heroku。
要在本地构建和安装,我运行以下命令:
这有效并输出
此应用程序将在本地运行而不会出现问题。但是,当我使用以下命令部署到 Heroku 时:
以下是输出:
我正在使用 govendor,所需的所有文件都位于我的应用程序的供应商目录中。我使用以下方法添加了它们:
问题是什么?有人有什么想法吗?
go - 获取登录的用户信息以进行显示
我正在使用https://github.com/kataras/iris Go 网络框架。我有:
- 用户注册
- 用户验证并登录
- 会话创建并
username
使用用户键设置(表和结构)username
现在,这是我的登录用户代码:
在 authcheck 中间件中
我的会话功能
现在,我的问题是,如何将 Logged User 值共享给模板中的所有路由。我当前的选择是:
但是上面代码的问题是,我将不得不为每条路线编写会话,并为我运行的每条路线再次运行查询,而不是共享。
我觉得,必须有更好的方法来做到这一点,而不是为每个路由加载会话两次,其中一个在authCheck
中间件中,第二个在内部allRoutes.Get
路由中。
我需要关于如何优化这一点的想法,并且只需编写一次代码而不是在下面为每条路线重复,就可以将用户数据共享到模板
go - Golang Iris: Initialize parent controller's model to child controller's model
I understand that Go is not an object-oriented language but I'm trying to implement a inheritance structure in my Iris controllers as suggested by this article. My main motivation for doing so is to avoid repetition. So far, it has been working for me. Take a look at the following code for example.
So far so good.
But I'm finding it difficult to replicate the same strategy for Models. This is what I've done so far
As you can see, the APIController is expecting type Models.Model
while UserController is passing *Models.User
. The end goal is to have a generic model in APIController that any model from any controller and then is able to call all the functions defined in Models.Model so that I don't have to call those function everywhere.
Is it possible to do so? If not, what might be the best approach to avoid repeating the code?
Update
By using inheritance and single parent model and using that in parent APIController
, I want to avoid replicating my filter/CRUD logic. For example, inside UserController
, if I want to save a record, then instead of using User.Save(input_data)
inside UserController
, the Save
should ideally be defined inside Models.Model
and from APIController
, I'm able to call Model.Save(input_data)
rather than making the same call from child controllers individually.
go - 在 Iris 框架中的 POST 方法中重定向
我正在尝试使用 POST 方法从登录页面重定向到主页,但单击提交按钮后表单不会重定向到任何页面。
我正在使用 Iris Framework 的 MVC 结构和Ctx.Redirect
重定向到所需页面的方法,但它不起作用。
表单 HTML 代码为:
不能在 Iris Framework/Go 中的 POST 方法中重定向吗?
go - 如何在 IRIS 中禁用自动转义
我将 HTML 标记插入到数据库表中:
并将检索到的数据发送到 View
我怎么能在这种情况下禁用自动转义?
go - 超时停止 goroutine 执行
我想在超时时停止执行 goroutine。但它似乎对我不起作用。我正在使用iris
框架。
输出:
预期输出:
有人可以指出这里缺少什么吗?它确实超时但仍然运行 goroutine 来打印test
和test1
. 我只想在超时后立即停止执行 goroutine。