代码拉取完成,页面将自动刷新
Dolphin is a simple web framework for Golang.
Install dolphin by Go cli tool:
go get -u github.com/ghosind/dolphin
Import dolphin in your code:
import "github.com/ghosind/dolphin"
The following example shows how to implement a simple web service, and it'll reads parameter name from request query and return the message as a JSON object.
package main
import (
"fmt"
"github.com/ghosind/dolphin"
)
func handler(ctx *dolphin.Context) {
name := ctx.Query("name")
ctx.JSON(ctx.O{
"message": fmt.Sprintf("Hello, %s", name),
})
}
func main() {
app := dolphin.Default()
app.Use(handler)
app.Run()
}
Save the above code as app.go
and run it with the following command:
go run app.go
# Server running at :8080.
Visit http://locahost:8080?name=dolphin
by your browser or other tools to see the result.
Distributed under the MIT License. See LICENSE file for more information.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。