const (
GET = "GET"
POST = "POST"
DELETE = "DELETE"
PATCH = "PATCH"
PUT = "PUT"
OPTIONS = "OPTIONS"
)
go get github.com/stainberg/koalart
import "github.com/stainberg/koalart"
package models
import (
"github.com/stainberg/koalart"
"net/http"
"io"
)
type KoalaController struct {
koala.Controller
}
func (k *KoalaController) URLMapping() {
k.Mapping(koala.GET, k.Get)
k.Mapping(koala.POST, k.Post)
}
func (c *KoalaController) Get() {
c.Ctx.Writer.WriteHeader(http.StatusOK)
io.WriteString(c.Ctx.Writer, `Get KoalaController`)
}
func (c *KoalaController) Post() {
c.Ctx.Writer.WriteHeader(http.StatusOK)
io.WriteString(c.Ctx.Writer, `Post KoalaController`)
}
package router
import (
"github.com/stainberg/koalart"
"models"
)
func init() {
ns := koala.NewNamespace("koala",
koala.NSController(new(models.KoalaController)),
)
koala.RegisterNamespace(ns)
}
package main
import (
_ "router"//init router
"github.com/stainberg/koalart"
)
func main() {
koala.Run("8888")
}