...
This commit is contained in:
parent
1350191dd4
commit
93eb265886
2 changed files with 14 additions and 14 deletions
|
@ -1,25 +1,25 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/omnipunk/bond"
|
"github.com/di4f/bond"
|
||||||
)
|
)
|
||||||
|
|
||||||
var root = bond.Mux().
|
var root = bond.Mux().
|
||||||
Def(
|
Def(
|
||||||
"",
|
"",
|
||||||
bond.ApiFunc(func(c *bond.Context){
|
bond.ApiFunc(func(c *bond.Context) {
|
||||||
c.W.Write([]byte("This is the index page"))
|
c.W.Write([]byte("This is the index page"))
|
||||||
}),
|
}),
|
||||||
).Def(
|
).Def(
|
||||||
"hello",
|
"hello",
|
||||||
bond.Mux().Def(
|
bond.Mux().Def(
|
||||||
"en",
|
"en",
|
||||||
bond.ApiFunc(func(c *bond.Context){
|
bond.ApiFunc(func(c *bond.Context) {
|
||||||
c.W.Write([]byte("Hello, World!"))
|
c.W.Write([]byte("Hello, World!"))
|
||||||
}),
|
}),
|
||||||
).Def(
|
).Def(
|
||||||
"ru",
|
"ru",
|
||||||
bond.ApiFunc(func(c *bond.Context){
|
bond.ApiFunc(func(c *bond.Context) {
|
||||||
c.W.Write([]byte("Привет, Мир!"))
|
c.W.Write([]byte("Привет, Мир!"))
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
@ -28,11 +28,11 @@ Def(
|
||||||
bond.Static("./static"),
|
bond.Static("./static"),
|
||||||
).Def(
|
).Def(
|
||||||
"test",
|
"test",
|
||||||
bond.ApiFunc(func(c *bond.Context){
|
bond.ApiFunc(func(c *bond.Context) {
|
||||||
c.SetContentType(bond.PlainText)
|
c.SetContentType(bond.PlainText)
|
||||||
c.Printf(
|
c.Printf(
|
||||||
"Path: %q\n" +
|
"Path: %q\n"+
|
||||||
"Content-Type: %q\n",
|
"Content-Type: %q\n",
|
||||||
c.Path(), c.ContentType(),
|
c.Path(), c.ContentType(),
|
||||||
)
|
)
|
||||||
c.Printf("Query:\n")
|
c.Printf("Query:\n")
|
||||||
|
@ -47,7 +47,7 @@ Def(
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
srv := bond.Server{
|
srv := bond.Server{
|
||||||
Addr: ":10800",
|
Addr: ":10800",
|
||||||
Handler: root,
|
Handler: root,
|
||||||
}
|
}
|
||||||
err := srv.ListenAndServe()
|
err := srv.ListenAndServe()
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -1,3 +1,3 @@
|
||||||
module github.com/omnipunk/bond
|
module github.com/di4f/bond
|
||||||
|
|
||||||
go 1.21.3
|
go 1.21.3
|
||||||
|
|
Loading…
Reference in a new issue