https://github.com/ysmood/goapi
A lightweight opinionated router to bridge function call and http api.
https://github.com/ysmood/goapi
Last synced: 8 months ago
JSON representation
A lightweight opinionated router to bridge function call and http api.
- Host: GitHub
- URL: https://github.com/ysmood/goapi
- Owner: ysmood
- License: mit
- Created: 2023-10-24T09:05:19.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-01-26T12:22:34.000Z (almost 2 years ago)
- Last Synced: 2024-06-22T15:49:54.140Z (over 1 year ago)
- Language: Go
- Size: 1.17 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Overview
A lightweight opinionated router to bridge function call and http api.
It helps to standardize the way to define input and output of a service.
## Features
- Auto generate openapi doc from code reflection
- Use function signature to define input and output
- Type safe without struct tags
## Usage
Hello world example: [main.go](lib/examples/hello-world/main.go).
RPC style example: [main.go](lib/examples/rpc/main.go).
Check the [examples folder](lib/examples/).
Read the tests for details.
## Benchmark
Without any optimization, goapi is about 7% slower than echo for the simplest usage.
This benchmark is only for avoiding drastic performance changes,
the real performance depends on the complexity of the service.
```text
go test -bench=. -benchmem ./lib/bench
goos: darwin
goarch: arm64
pkg: github.com/ysmood/goapi/lib/bench
Benchmark_goapi-12 34472 33856 ns/op 8448 B/op 114 allocs/op
Benchmark_echo-12 36729 31175 ns/op 6776 B/op 82 allocs/op
PASS
ok github.com/ysmood/goapi/lib/bench 5.711s
```