4
This commit is contained in:
parent
1215fadcbf
commit
4e11d7f366
6 changed files with 152 additions and 15 deletions
|
|
@ -4,10 +4,10 @@ WORKDIR /go/src/app
|
||||||
|
|
||||||
# Get Reflex for live reload in dev
|
# Get Reflex for live reload in dev
|
||||||
ENV GO111MODULE=on
|
ENV GO111MODULE=on
|
||||||
RUN go get github.com/cespare/reflex
|
RUN go install github.com/cespare/reflex@latest
|
||||||
|
|
||||||
COPY go.mod .
|
COPY go.mod .
|
||||||
COPY go.sum .
|
# COPY ./app/go.sum .
|
||||||
|
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
|
|
@ -22,5 +22,5 @@ WORKDIR /root/
|
||||||
#Copy executable from builder
|
#Copy executable from builder
|
||||||
COPY --from=builder /go/src/app/run .
|
COPY --from=builder /go/src/app/run .
|
||||||
|
|
||||||
EXPOSE 8080
|
# EXPOSE 8080
|
||||||
CMD ["./run"]
|
CMD ["./run"]
|
||||||
|
|
|
||||||
19
app/certs/ssl.crt
Normal file
19
app/certs/ssl.crt
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDGzCCAgOgAwIBAgIUOc2GVRyF7sOa2RIemBJQSsHL+GswDQYJKoZIhvcNAQEL
|
||||||
|
BQAwGDEWMBQGA1UEAwwNKi5kaXVrbWFuLmNvbTAeFw0yNDA4MTQwNTA1MDBaFw0y
|
||||||
|
NDA5MTMwNTA1MDBaMBgxFjAUBgNVBAMMDSouZGl1a21hbi5jb20wggEiMA0GCSqG
|
||||||
|
SIb3DQEBAQUAA4IBDwAwggEKAoIBAQCbv/wWLzklElyDOFufiTk0zdXFWuFlamxF
|
||||||
|
5p4XdYrflOY4ivFAa+QMO0fjGJj2WBoJ44uXVv1HfEmFNDSmFev0FnfEyVvftClq
|
||||||
|
5s5dPXOZ2uOAKIpurNZ7ik+amAuJjwFHzcRBQPUkbQoLP/LuoTXO4W76itvs1L/q
|
||||||
|
MzIRF3E1jZick9KcYnq+s/UJSaYIMdamGC/aojuiJW9y3wktQeNGxouvgQZrH2Dt
|
||||||
|
7aYcNFxeSrxJ+M7PUdX9rPJ3k51dUtR/yCuVMFRBa2kLq9QWRv6jGcx8qeKIFHme
|
||||||
|
dJydpQVPiYpAHlW4x/sAo8va/HzSg50IjS0hbMnEtuHaGFmOuw9DAgMBAAGjXTBb
|
||||||
|
MBgGA1UdEQQRMA+CDSouZGl1a21hbi5jb20wCwYDVR0PBAQDAgeAMBMGA1UdJQQM
|
||||||
|
MAoGCCsGAQUFBwMBMB0GA1UdDgQWBBQExv/wzqFffu3LFtjpu80wAuBMMDANBgkq
|
||||||
|
hkiG9w0BAQsFAAOCAQEAKrf9Q8qSxs0noUttl724n6TcKIvoEvNXd13YXUDTsbg6
|
||||||
|
sIZ0JXb8U1jKNXW21l2/VR/ymOJMUu2iUkQ2ZtveI6/tgw7HdMtVB82eFUUm3geH
|
||||||
|
hBgwBA7FiApcp6iD031umHCgIJcQapWa5UyaGDlYhbYP9mHL3hbrZaCwdxQ7cK6n
|
||||||
|
Oy2m/48bt5bWnLoCHpYgrq6pj97KYEmQS6ba262cL5W8XJAcC+RN/NtDlCar9Xk/
|
||||||
|
4rugvIzT3+yIMBhPMqUFxctea7+Fv4ft36s0OMfQ2iPcHlU8sJhQ6MQoAq8FR3K5
|
||||||
|
GUhnt3kgouVzHPTEDOhVuNIBL7j8VNzZxLLLyD+0+g==
|
||||||
|
-----END CERTIFICATE-----
|
||||||
28
app/certs/ssl.key
Normal file
28
app/certs/ssl.key
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIEuwIBADANBgkqhkiG9w0BAQEFAASCBKUwggShAgEAAoIBAQCbv/wWLzklElyD
|
||||||
|
OFufiTk0zdXFWuFlamxF5p4XdYrflOY4ivFAa+QMO0fjGJj2WBoJ44uXVv1HfEmF
|
||||||
|
NDSmFev0FnfEyVvftClq5s5dPXOZ2uOAKIpurN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I/QKBgC53VSClXrHYSb/N595QvpnoNvMKxsoK6Gg1hJcYqIsV2Xorns9h
|
||||||
|
a+y1MRw6oZ0Z2Kc1AA9iMi6dUoFVx4TR6PBHqIemhGfsyTC5E0jHM9ptsm9/utPB
|
||||||
|
F+wrKPcMUHMBywDdg1MMokpRUxVwvYXugyOZTFuLYSb18ywiH6xNBjP9AoGBAMG+
|
||||||
|
b8lc5ExS9Dxhb+uIxRCf2SzH4Dqvh6vR78bGnuKWo5WgGxpDbh1lxnrSolgQQFlH
|
||||||
|
pIw2+th6Ijvz2hm5cCCUgh7nOAzo0m7AmA7f6mfnid++NqDXv9pniuMvq7pyiKOu
|
||||||
|
ti4ahZQ70xGuwOfJC0PC+O94YTcJxqSm3aIi1EglAn8Nq+SYWhhDbYVtsWjKj6Z5
|
||||||
|
ILHHE6DFw7Ne3PEn1mVg/IM0l3JHHpHKJnytuXG/mzcktzMjo3mRI30YRzmvzu93
|
||||||
|
v+XWRcSyU74K+vM+9aZ331TJL90CGCm1zezo6OKA+KOebCTRo0Lw3bynFPffwPK/
|
||||||
|
nN9cWJDNRW1Pvb2OI8jp
|
||||||
|
-----END PRIVATE KEY-----
|
||||||
93
app/main.go
93
app/main.go
|
|
@ -11,26 +11,103 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
sslCert = "./certs/ssl.crt"
|
||||||
|
sslKey = "./certs/ssl.key"
|
||||||
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
fmt.Println("ZPROX started")
|
fmt.Println("ZPROX started")
|
||||||
}
|
}
|
||||||
func handler1(w http.ResponseWriter, r *http.Request) {
|
|
||||||
if r.Host == "test.gotest.com" {
|
|
||||||
w.Write([]byte("H1"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// type Matcher struct {
|
||||||
|
// r *http.Request
|
||||||
|
// w http.ResponseWriter
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func (m *Matcher) MatchHost(str string, f ...func(w http.ResponseWriter, r *http.Request)) {
|
||||||
|
// if m.r.Host == "test.gotest.com" || m.r.Host == "localhost" {
|
||||||
|
// m.w.Write([]byte("test"))
|
||||||
|
// } else {
|
||||||
|
// m.w.Write([]byte("404 page not found"))
|
||||||
|
// m.w.WriteHeader(http.StatusNotFound)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
type HandlerFunc func(http.ResponseWriter, *http.Request)
|
||||||
|
|
||||||
|
// func (h *HandlerFunc) Handle(f func(w http.ResponseWriter, r *http.Request)) {
|
||||||
|
// h = h.HandlerFunc()
|
||||||
|
|
||||||
|
// // &h.f()
|
||||||
|
// // if r.Host == "test.gotest.com" {
|
||||||
|
// // w.Write([]byte("test"))
|
||||||
|
// // } else {
|
||||||
|
// // w.Write([]byte("404 page not found"))
|
||||||
|
|
||||||
|
// // w.WriteHeader(http.StatusNotFound)
|
||||||
|
// // }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func test(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// if r.Host == "test.gotest.com" {
|
||||||
|
// w.Write([]byte("login"))
|
||||||
|
// } else {
|
||||||
|
// w.Write([]byte("404 page not found"))
|
||||||
|
// w.WriteHeader(http.StatusNotFound)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func handle(f HandlerFunc) HandlerFunc {
|
||||||
|
// HandlerFunc{}.f[0]
|
||||||
|
// return func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
// f
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// type Mux struct {
|
||||||
|
// *Handlers
|
||||||
|
// *Router
|
||||||
|
// }
|
||||||
|
// type Handlers []struct{ http.Handler }
|
||||||
|
// type Router struct{ *http.ServeMux }
|
||||||
|
|
||||||
|
// func NewMux() *Mux {
|
||||||
|
// r := new(Router)
|
||||||
|
// h := new(Handlers)
|
||||||
|
// return &Mux{Handlers:h,Router:r}
|
||||||
|
// }
|
||||||
|
|
||||||
|
// func (m *Handlers) Add() {
|
||||||
|
// h := new(Handlers)
|
||||||
|
// m = &Mux{h, r}
|
||||||
|
// &Handlers{f}
|
||||||
|
// }
|
||||||
|
type Router struct{ http.ServeMux }
|
||||||
|
|
||||||
|
func (r Router) Host(string) {
|
||||||
|
|
||||||
|
// router.HandleFunc("")
|
||||||
|
}
|
||||||
func main() {
|
func main() {
|
||||||
|
// var h HandlerFunc
|
||||||
|
// h:=func(a HandlerFunc)HandlerFunc{
|
||||||
|
|
||||||
router := http.NewServeMux()
|
router := http.NewServeMux()
|
||||||
router.Handle("/", http.HandlerFunc(handler1))
|
router.H
|
||||||
|
// h := Handler.Add(func(w http.ResponseWriter, r *http.Request) {})
|
||||||
|
// http.Handler.ServeHTTP()
|
||||||
|
|
||||||
|
router.HandleFunc("test.gotest.com/", h)
|
||||||
|
// router.HandleFunc("login.gotest.com/", login)
|
||||||
|
|
||||||
srv := &http.Server{
|
srv := &http.Server{
|
||||||
Addr: ":80",
|
Addr: ":8443",
|
||||||
Handler: router,
|
Handler: router,
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
if err := srv.ListenAndServeTLS(sslCert, sslKey); err != nil && err != http.ErrServerClosed {
|
||||||
log.Fatalf("Failed to initialize server: %v\n", err)
|
log.Fatalf("Failed to initialize server: %v\n", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
|
||||||
|
|
@ -1,17 +1,19 @@
|
||||||
services:
|
services:
|
||||||
account:
|
zprox:
|
||||||
build:
|
build:
|
||||||
context: ./app
|
context: ./app
|
||||||
target: builder
|
target: builder
|
||||||
image: account
|
image: zprox
|
||||||
expose:
|
ports:
|
||||||
- "8080"
|
- "80:8080"
|
||||||
|
- "443:8443"
|
||||||
environment:
|
environment:
|
||||||
- ENV=dev
|
- ENV=dev
|
||||||
volumes:
|
volumes:
|
||||||
- ./app:/go/src/app
|
- ./app:/go/src/app
|
||||||
# have to use $$ (double-dollar) so docker doesn't try to substitute a variable
|
# have to use $$ (double-dollar) so docker doesn't try to substitute a variable
|
||||||
command: reflex -r "\.go$$" -s -- sh -c "go run ./"
|
command: reflex -r "\.go$$" -s -- sh -c "go run ./"
|
||||||
|
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres:latest
|
image: postgres:latest
|
||||||
restart: always
|
restart: always
|
||||||
|
|
@ -53,3 +55,6 @@ services:
|
||||||
- "quarkus.transaction-manager.enable-recovery=true"
|
- "quarkus.transaction-manager.enable-recovery=true"
|
||||||
networks:
|
networks:
|
||||||
postgres:
|
postgres:
|
||||||
|
|
||||||
|
# networks:
|
||||||
|
# - host
|
||||||
8
zprox.code-workspace
Normal file
8
zprox.code-workspace
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue