Update generator (#37)

This commit is contained in:
Jonas Plum
2022-03-12 21:09:10 +01:00
committed by GitHub
parent eced5df7c8
commit d353268cf2
28 changed files with 1303 additions and 1618 deletions

File diff suppressed because it is too large Load Diff

1129
generated/api/server.go Executable file

File diff suppressed because it is too large Load Diff

25
generated/api/static.go Executable file
View File

@@ -0,0 +1,25 @@
package api
import (
"io/fs"
"net/http"
"net/http/httputil"
"net/url"
)
func Static(fsys fs.FS) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
http.FileServer(http.FS(fsys)).ServeHTTP(w, r)
}
}
func Proxy(dest string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
u, _ := url.Parse(dest)
proxy := httputil.NewSingleHostReverseProxy(u)
r.Host = r.URL.Host
proxy.ServeHTTP(w, r)
}
}

19
generated/pointer/pointer.go Executable file
View File

@@ -0,0 +1,19 @@
package pointer
import "time"
func String(v string) *string {
return &v
}
func Int64(v int64) *int64 {
return &v
}
func Bool(v bool) *bool {
return &v
}
func Time(v time.Time) *time.Time {
return &v
}

19
generated/time/time.go Executable file
View File

@@ -0,0 +1,19 @@
package time
import "time"
type Clock interface {
Now() time.Time
}
type realClock struct{}
func (realClock) Now() time.Time {
return time.Now()
}
var DefaultClock Clock = &realClock{}
func Now() time.Time {
return DefaultClock.Now()
}