mirror of
https://github.com/openfaas/faasd.git
synced 2025-06-21 00:06:37 +00:00
Add proxy to faasd up
Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
This commit is contained in:
committed by
Alex Ellis
parent
52baca9d17
commit
ff0cccf0dc
33
pkg/proxy.go
Normal file
33
pkg/proxy.go
Normal file
@ -0,0 +1,33 @@
|
||||
package pkg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"time"
|
||||
)
|
||||
|
||||
func NewProxy(hosts string, timeout time.Duration) *Proxy {
|
||||
|
||||
return &Proxy{
|
||||
Hosts: hosts,
|
||||
Timeout: timeout,
|
||||
}
|
||||
}
|
||||
|
||||
type Proxy struct {
|
||||
Hosts string
|
||||
Timeout time.Duration
|
||||
}
|
||||
|
||||
func (p *Proxy) Start() error {
|
||||
tcp := 8080
|
||||
s := &http.Server{
|
||||
Addr: fmt.Sprintf(":%d", tcp),
|
||||
ReadTimeout: p.Timeout,
|
||||
WriteTimeout: p.Timeout,
|
||||
MaxHeaderBytes: 1 << 20, // Max header of 1MB
|
||||
}
|
||||
|
||||
return s.ListenAndServe()
|
||||
}
|
Reference in New Issue
Block a user