fun: HTTP RPC framework with DI, guards, streams and codegen
- Service binding via reflection with 4 method signatures - Dependency injection (Wired/auto tags) and guards - Streamable HTTP (NDJSON) streaming responses - Go/TypeScript client code generation (self-contained, with interceptors) - Enum support, structured Result, logging - 16 regression tests covering all fixed bugs
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
package fun
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Tag struct {
|
||||
TagList map[string]string
|
||||
}
|
||||
|
||||
func newTag(tag reflect.StructTag) *Tag {
|
||||
t := &Tag{
|
||||
TagList: map[string]string{},
|
||||
}
|
||||
pairs := strings.Split(strings.TrimSpace(tag.Get("fun")), ";")
|
||||
for _, pair := range pairs {
|
||||
if pair == "" {
|
||||
continue
|
||||
}
|
||||
keyValue := strings.Split(pair, ":")
|
||||
if len(keyValue) == 1 {
|
||||
t.TagList[keyValue[0]] = ""
|
||||
} else {
|
||||
t.TagList[keyValue[0]] = keyValue[1]
|
||||
}
|
||||
}
|
||||
return t
|
||||
}
|
||||
|
||||
func (tag *Tag) getTag(key string) (string, bool) {
|
||||
v, ok := tag.TagList[key]
|
||||
return v, ok
|
||||
}
|
||||
Reference in New Issue
Block a user