add mime
This commit is contained in:
parent
f57bd4d937
commit
5fdb7de83d
|
@ -8,7 +8,7 @@
|
||||||
"name": "Launch",
|
"name": "Launch",
|
||||||
"type": "go",
|
"type": "go",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
"mode": "auto",
|
"mode": "debug",
|
||||||
"program": "${workspaceFolder}",
|
"program": "${workspaceFolder}",
|
||||||
"env": {
|
"env": {
|
||||||
"GODEBUG": "cgocheck=0",
|
"GODEBUG": "cgocheck=0",
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
],
|
],
|
||||||
"showLog": true,
|
"showLog": true,
|
||||||
"trace": "log",
|
"trace": "log",
|
||||||
|
"dlvFlags": ["--check-go-version=false"]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
20
Makefile
20
Makefile
|
@ -1,13 +1,15 @@
|
||||||
BINARY_NAME=target/gohttpd
|
ARCHS := amd64 arm64
|
||||||
|
VERSION ?= $(shell git describe --tags --always)
|
||||||
|
all:$(ARCHS)
|
||||||
|
|
||||||
all:build
|
$(ARCHS):
|
||||||
|
@echo "Building for $(@)"
|
||||||
build:
|
@GOOS=linux GOARCH=$(@)
|
||||||
go build -o ${BINARY_NAME}
|
go build -ldflags "-X main.Version=$(VERSION)" -o target/$(@)/gohttpd
|
||||||
cp config.json target/
|
cp config.json target/$(@)/
|
||||||
cp -r adminui target/
|
cp -r adminui target/$(@)/
|
||||||
cp gohttpd.service target/
|
cp gohttpd.service target/$(@)/
|
||||||
cp install.sh target/
|
cp install.sh target/$(@)/
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
go clean
|
go clean
|
||||||
|
|
313
config.json
313
config.json
|
@ -1,29 +1,32 @@
|
||||||
{
|
{
|
||||||
"logging" :{
|
"logging": {
|
||||||
"appenders": {
|
"appenders": {
|
||||||
"out" :{
|
"out": {
|
||||||
"type": "file",
|
"type": "file",
|
||||||
"options":{
|
"options": {
|
||||||
"file": "gohttpd.log"
|
"file": "gohttpd.log"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stdout":{
|
"stdout": {
|
||||||
"type": "console"
|
"type": "console"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"categories": {
|
"categories": {
|
||||||
"default": {
|
"default": {
|
||||||
"appenders": [ "out" ,"stdout"],
|
"appenders": [
|
||||||
|
"out",
|
||||||
|
"stdout"
|
||||||
|
],
|
||||||
"level": "debug"
|
"level": "debug"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"admin" : {
|
"admin": {
|
||||||
"name": "admin",
|
"name": "admin",
|
||||||
"port" : 8088,
|
"port": 8088,
|
||||||
"username": "admin",
|
"username": "admin",
|
||||||
"password": "admin",
|
"password": "admin",
|
||||||
"directives":[
|
"directives": [
|
||||||
"Set-Header Access-Control-Allow-Origin *",
|
"Set-Header Access-Control-Allow-Origin *",
|
||||||
"Set-Header Access-Control-Allow-Methods GET, POST, PUT, DELETE, OPTIONS",
|
"Set-Header Access-Control-Allow-Methods GET, POST, PUT, DELETE, OPTIONS",
|
||||||
"Set-Header Access-Control-Allow-Headers Content-Type, Authorization, Content-Length, X-Requested-With"
|
"Set-Header Access-Control-Allow-Headers Content-Type, Authorization, Content-Length, X-Requested-With"
|
||||||
|
@ -31,109 +34,213 @@
|
||||||
"paths": [
|
"paths": [
|
||||||
{
|
{
|
||||||
"path": "/",
|
"path": "/",
|
||||||
"upstreams": ["http://localhost:4200"],
|
"root": "./adminui",
|
||||||
"directives":["HostSchemas $target"]
|
"default": "index.html"
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"jwt":{
|
|
||||||
"secret": "cloudops",
|
|
||||||
"expiresIn": "1h",
|
|
||||||
"issuer": "cloudops",
|
|
||||||
"audience": "cloudops"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"servers":[{
|
"servers": [
|
||||||
"port": 3000,
|
{
|
||||||
"name": "cloudops",
|
"port": 3001,
|
||||||
"directives":[
|
"name": "installui",
|
||||||
|
"directives": [
|
||||||
"Gzip_Response"
|
"Gzip_Response"
|
||||||
],
|
],
|
||||||
"paths":[
|
"paths":[
|
||||||
|
|
||||||
{
|
{
|
||||||
"path" : "/ssologin",
|
"path": "/",
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
"upstreams": [
|
||||||
"directives":["HostSchemas $target"]
|
"http://localhost:4200"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"path" : "/themes",
|
"path":"/ib",
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
"upstreams": [
|
||||||
"directives":["HostSchemas $target"]
|
"http://localhost:8080"
|
||||||
},
|
],
|
||||||
{
|
"directives": [
|
||||||
"path" : "/security/login",
|
"HostSchemas $target"
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":["HostSchemas $target"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/security/logout",
|
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":["HostSchemas $target"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/v1/relational/assets",
|
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":["HostSchemas $target"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/platform/version",
|
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":["HostSchemas $target"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/v1/patrolrecords",
|
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":["HostSchemas $target"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/v1/standingbook",
|
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":["HostSchemas $target"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/v1/resource",
|
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":["HostSchemas $target"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/v1/config",
|
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":["HostSchemas $target"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/v1/workflow",
|
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":["HostSchemas $target"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path":"/token/check",
|
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":["HostSchemas $target"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/v1/messages",
|
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":["HostSchemas $target"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/cloudops-state/",
|
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":["HostSchemas $target"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path":"/socket.io/",
|
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":["HostSchemas $target"]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"path" : "/thing",
|
|
||||||
"upstreams": ["http://192.168.12.157:9880"],
|
|
||||||
"directives":[
|
|
||||||
"HostSchemas $target",
|
|
||||||
"HeaderOrigin",
|
|
||||||
"RemoveCookie token"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}]
|
},
|
||||||
}
|
{
|
||||||
|
"port": 3000,
|
||||||
|
"name": "cloudops",
|
||||||
|
"directives": [
|
||||||
|
"Gzip_Response"
|
||||||
|
],
|
||||||
|
"paths": [
|
||||||
|
{
|
||||||
|
"path": "/",
|
||||||
|
"upstreams": [
|
||||||
|
"http://localhost:4200"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/ssologin",
|
||||||
|
"upstreams": [
|
||||||
|
"http://localhost:4200"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/themes",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/security",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/v1/relational/assets",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/platform/version",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/v1/patrolrecords",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/v1/standingbook",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/v1/resource",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/v1/config",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/v1/workflow",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/token/check",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/v1/messages",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/cloudops-state/",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/socket.io/",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/v1/stream",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.157:9880"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "/thing",
|
||||||
|
"upstreams": [
|
||||||
|
"http://192.168.12.204:1662"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target",
|
||||||
|
"HeaderOrigin",
|
||||||
|
"RemoveCookie token"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path":"/ib",
|
||||||
|
"upstreams": [
|
||||||
|
"http://localhost:8080"
|
||||||
|
],
|
||||||
|
"directives": [
|
||||||
|
"HostSchemas $target",
|
||||||
|
"HeaderOrigin",
|
||||||
|
"RemoveCookie token"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package handler
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"mime"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
@ -66,3 +67,13 @@ func FileExists(name string) (os.FileInfo, bool, error) {
|
||||||
func NewFileHandler(f FileHandler) http.Handler {
|
func NewFileHandler(f FileHandler) http.Handler {
|
||||||
return http.FileServer(f)
|
return http.FileServer(f)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
mime.AddExtensionType(".js", "application/javascript")
|
||||||
|
mime.AddExtensionType(".css", "text/css")
|
||||||
|
mime.AddExtensionType(".html", "text/html")
|
||||||
|
mime.AddExtensionType(".htm", "text/html")
|
||||||
|
mime.AddExtensionType(".svg", "image/svg+xml")
|
||||||
|
mime.AddExtensionType(".png", "image/png")
|
||||||
|
mime.AddExtensionType(".mjs", "application/javascript")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue