Raptor
Slim and fast like a raptor
Install / Use
/learn @si3nloong/RaptorREADME
Raptor Web Framework
Inspired by Laravel and Iris
Why Raptor web framework? We love fasthttp, we love speed. Basically Raptor is using fasthttp, fasthttprouter, ffjson packages under the hood.
Installation
The only requirement is the Go Programming Language
$ go get -u github.com/si3nloong/raptor
Quick Start
package main
import (
"github.com/si3nloong/raptor"
)
func main() {
r := raptor.New()
r.GET("/", func(c *raptor.Context) error {
return c.JSON(raptor.Map{"message":"hello world"})
})
r.Start(":8080")
}
Multiple Hosts
import (
"github.com/si3nloong/raptor"
)
type host map[string]raptor.HandlerFunc
// Routing is to route to specific domain
func (hs host) Routing(ctx *raptor.Context) error {
if cb := hosts[string(ctx.Host())]; cb != nil {
cb = middleware.CORS(corsConfig)(cb)
return cb(ctx)
}
return ctx.JSON(fmt.Errorf("page not found"), fasthttp.StatusNotFound)
}
func main() {
api := raptor.New()
api.GET("/", func(c *raptor.Context) error {
return c.JSON(raptor.Map{"message":"hello world"})
})
open := raptor.New()
open.GET("/", func(c *raptor.Context) error {
return c.JSON(raptor.Map{"message":"hello world"})
})
hosts["api.domain.com"] = api.Handler()
hosts["open.domain.com"] = open.Handler()
r := raptor.New()
r.Start(":8080", hosts.Routing)
}
Variable Binding
api := raptor.New()
api.GET("/", func(c *raptor.Context) error {
var i struct {
Name string `json:"name" xml:"name" query:"name"`
}
if err := c.Bind(&i); err != nil {
return err
}
return c.JSON(raptor.Map{"message":"hello world"})
})
api.Start(":8080")
Validation
api := raptor.New()
api.GET("/", func(c *raptor.Context) error {
var i struct {
Name string `json:"name" xml:"name" query:"name"`
}
if err := c.Bind(&i); err != nil {
return err
}
if message, err := c.Validate(&i); err != nil {
return err
}
return c.JSON(raptor.Map{"message":"hello world"})
})
api.Start(":8080")
Error Handling
Custom Error
Related Skills
node-connect
348.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
xurl
348.2kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
frontend-design
108.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
348.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
