package main import ( "vultras.su/core/bond" //"vultras.su/core/bond/methods" "vultras.su/core/bond/statuses" "fmt" "io" "net/url" "encoding/json" ) type GetNotesOptions struct { Id int `json:"id"` Name string `json:"name"` } var root = bond.Root(bond.Path(). Def( "hook", /*bond.Method().Def( methods.Post,*/ bond.Func(func(c *bond.Context){ fmt.Printf("Content-Type: %q\n", c.ContentType()) body, err := io.ReadAll(c.R.Body) if err != nil { fmt.Printf("err:%s\n", err) return } fmt.Printf("rawBody: %q\n", body) unesc, err := url.QueryUnescape(string(body)) if err != nil { fmt.Printf("err:%s\n", err) return } fmt.Printf("unescapeBody: %q\n", unesc) mp := map[string] any{} err = bond.ParseStr(unesc, mp) if err != nil { fmt.Printf("err:%s\n", err) return } js, err := json.MarshalIndent(mp, "", "\t") if err != nil { fmt.Printf("err:%s\n", err) return } fmt.Printf("\nparsed: %v\n", string(js)) c.SetStatus(statuses.OK) }), //), )) func main() { srv := bond.Server{ Addr: ":15080", Handler: root, } err := srv.ListenAndServe() if err != nil { panic(err) } }