Skip to content

Commit

Permalink
rm: example code
Browse files Browse the repository at this point in the history
  • Loading branch information
leozqin committed Oct 15, 2024
1 parent 2b61b8f commit 42152ee
Showing 1 changed file with 0 additions and 26 deletions.
26 changes: 0 additions & 26 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"context"
"encoding/json"
"fmt"
"log"
"net/http"

Expand All @@ -19,25 +18,6 @@ import (

const version = "0.0.1"

// GreetingOutput represents the greeting operation response.
type GreetingOutput struct {
Body struct {
Message string `json:"message" example:"Hello, world!" doc:"Greeting message"`
}
}

// GreetingInput represents the greeting operation request.
type GreetingInput struct {
Name string `path:"name" maxLength:"30" example:"world" doc:"Name to greet"`
}

func Greeting(input GreetingInput) GreetingOutput {
output := &GreetingOutput{}
output.Body.Message = fmt.Sprintf("Hello, %s!", input.Name)

return *output
}

func main() {
db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
if err != nil {
Expand All @@ -49,12 +29,6 @@ func main() {
router := chi.NewMux()
api := humachi.New(router, huma.DefaultConfig("Laridae", version))

huma.Get(api, "/greeting/{name}", func(ctx context.Context, input *GreetingInput) (*GreetingOutput, error) {
resp := Greeting(*input)

return &resp, nil
})

huma.Get(api, "/list/tools", func(ctx context.Context, input *struct{}) (*ListToolOutput, error) {
resp := ListTools(*db)
out := ListToolOutput{Body: resp}
Expand Down

0 comments on commit 42152ee

Please sign in to comment.