mirror of
https://github.com/SecurityBrewery/catalyst.git
synced 2025-12-06 23:32:47 +01:00
Update generator (#37)
This commit is contained in:
25
generated/api/static.go
Executable file
25
generated/api/static.go
Executable 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user