mirror of
https://github.com/Fishwaldo/huma.git
synced 2025-03-15 19:31:27 +00:00
27 lines
557 B
Go
27 lines
557 B
Go
package main
|
|
|
|
import (
|
|
"github.com/danielgtaylor/huma"
|
|
"github.com/danielgtaylor/huma/cli"
|
|
"github.com/danielgtaylor/huma/responses"
|
|
)
|
|
|
|
func routes(r *huma.Router) {
|
|
// Register a single test route that returns a text/plain response.
|
|
r.Resource("/test").Get("test", "Test route",
|
|
responses.OK().ContentType("text/plain"),
|
|
).Run(func(ctx huma.Context) {
|
|
ctx.Write([]byte("Hello, test!"))
|
|
})
|
|
}
|
|
|
|
func main() {
|
|
// Create the router.
|
|
app := cli.NewRouter("Test", "1.0.0")
|
|
|
|
// Register routes.
|
|
routes(app.Router)
|
|
|
|
// Run the service.
|
|
app.Run()
|
|
}
|