add mime
This commit is contained in:
parent
f57bd4d937
commit
5fdb7de83d
|
@ -8,7 +8,7 @@
|
|||
"name": "Launch",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"mode": "debug",
|
||||
"program": "${workspaceFolder}",
|
||||
"env": {
|
||||
"GODEBUG": "cgocheck=0",
|
||||
|
@ -20,6 +20,7 @@
|
|||
],
|
||||
"showLog": true,
|
||||
"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
|
||||
|
||||
build:
|
||||
go build -o ${BINARY_NAME}
|
||||
cp config.json target/
|
||||
cp -r adminui target/
|
||||
cp gohttpd.service target/
|
||||
cp install.sh target/
|
||||
$(ARCHS):
|
||||
@echo "Building for $(@)"
|
||||
@GOOS=linux GOARCH=$(@)
|
||||
go build -ldflags "-X main.Version=$(VERSION)" -o target/$(@)/gohttpd
|
||||
cp config.json target/$(@)/
|
||||
cp -r adminui target/$(@)/
|
||||
cp gohttpd.service target/$(@)/
|
||||
cp install.sh target/$(@)/
|
||||
|
||||
clean:
|
||||
go clean
|
||||
|
|
249
config.json
249
config.json
|
@ -1,29 +1,32 @@
|
|||
{
|
||||
"logging" :{
|
||||
"logging": {
|
||||
"appenders": {
|
||||
"out" :{
|
||||
"out": {
|
||||
"type": "file",
|
||||
"options":{
|
||||
"options": {
|
||||
"file": "gohttpd.log"
|
||||
}
|
||||
},
|
||||
"stdout":{
|
||||
"stdout": {
|
||||
"type": "console"
|
||||
}
|
||||
},
|
||||
"categories": {
|
||||
"default": {
|
||||
"appenders": [ "out" ,"stdout"],
|
||||
"appenders": [
|
||||
"out",
|
||||
"stdout"
|
||||
],
|
||||
"level": "debug"
|
||||
}
|
||||
}
|
||||
},
|
||||
"admin" : {
|
||||
"admin": {
|
||||
"name": "admin",
|
||||
"port" : 8088,
|
||||
"port": 8088,
|
||||
"username": "admin",
|
||||
"password": "admin",
|
||||
"directives":[
|
||||
"directives": [
|
||||
"Set-Header Access-Control-Allow-Origin *",
|
||||
"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"
|
||||
|
@ -31,109 +34,213 @@
|
|||
"paths": [
|
||||
{
|
||||
"path": "/",
|
||||
"upstreams": ["http://localhost:4200"],
|
||||
"directives":["HostSchemas $target"]
|
||||
}
|
||||
],
|
||||
"jwt":{
|
||||
"secret": "cloudops",
|
||||
"expiresIn": "1h",
|
||||
"issuer": "cloudops",
|
||||
"audience": "cloudops"
|
||||
"root": "./adminui",
|
||||
"default": "index.html"
|
||||
}
|
||||
]
|
||||
},
|
||||
"servers":[{
|
||||
"port": 3000,
|
||||
"name": "cloudops",
|
||||
"directives":[
|
||||
"servers": [
|
||||
{
|
||||
"port": 3001,
|
||||
"name": "installui",
|
||||
"directives": [
|
||||
"Gzip_Response"
|
||||
],
|
||||
"paths":[
|
||||
|
||||
{
|
||||
"path" : "/ssologin",
|
||||
"upstreams": ["http://192.168.12.157:9880"],
|
||||
"directives":["HostSchemas $target"]
|
||||
"path": "/",
|
||||
"upstreams": [
|
||||
"http://localhost:4200"
|
||||
],
|
||||
"directives": [
|
||||
"HostSchemas $target"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path" : "/themes",
|
||||
"upstreams": ["http://192.168.12.157:9880"],
|
||||
"directives":["HostSchemas $target"]
|
||||
"path":"/ib",
|
||||
"upstreams": [
|
||||
"http://localhost:8080"
|
||||
],
|
||||
"directives": [
|
||||
"HostSchemas $target"
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"path" : "/security/login",
|
||||
"upstreams": ["http://192.168.12.157:9880"],
|
||||
"directives":["HostSchemas $target"]
|
||||
"port": 3000,
|
||||
"name": "cloudops",
|
||||
"directives": [
|
||||
"Gzip_Response"
|
||||
],
|
||||
"paths": [
|
||||
{
|
||||
"path": "/",
|
||||
"upstreams": [
|
||||
"http://localhost:4200"
|
||||
],
|
||||
"directives": [
|
||||
"HostSchemas $target"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path" : "/security/logout",
|
||||
"upstreams": ["http://192.168.12.157:9880"],
|
||||
"directives":["HostSchemas $target"]
|
||||
"path": "/ssologin",
|
||||
"upstreams": [
|
||||
"http://localhost:4200"
|
||||
],
|
||||
"directives": [
|
||||
"HostSchemas $target"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path" : "/v1/relational/assets",
|
||||
"upstreams": ["http://192.168.12.157:9880"],
|
||||
"directives":["HostSchemas $target"]
|
||||
"path": "/themes",
|
||||
"upstreams": [
|
||||
"http://192.168.12.157:9880"
|
||||
],
|
||||
"directives": [
|
||||
"HostSchemas $target"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path" : "/platform/version",
|
||||
"upstreams": ["http://192.168.12.157:9880"],
|
||||
"directives":["HostSchemas $target"]
|
||||
"path": "/security",
|
||||
"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/relational/assets",
|
||||
"upstreams": [
|
||||
"http://192.168.12.157:9880"
|
||||
],
|
||||
"directives": [
|
||||
"HostSchemas $target"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path" : "/v1/standingbook",
|
||||
"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/resource",
|
||||
"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/config",
|
||||
"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/workflow",
|
||||
"upstreams": ["http://192.168.12.157:9880"],
|
||||
"directives":["HostSchemas $target"]
|
||||
"path": "/v1/resource",
|
||||
"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/config",
|
||||
"upstreams": [
|
||||
"http://192.168.12.157:9880"
|
||||
],
|
||||
"directives": [
|
||||
"HostSchemas $target"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path" : "/v1/messages",
|
||||
"upstreams": ["http://192.168.12.157:9880"],
|
||||
"directives":["HostSchemas $target"]
|
||||
"path": "/v1/workflow",
|
||||
"upstreams": [
|
||||
"http://192.168.12.157:9880"
|
||||
],
|
||||
"directives": [
|
||||
"HostSchemas $target"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path" : "/cloudops-state/",
|
||||
"upstreams": ["http://192.168.12.157:9880"],
|
||||
"directives":["HostSchemas $target"]
|
||||
"path": "/token/check",
|
||||
"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/messages",
|
||||
"upstreams": [
|
||||
"http://192.168.12.157:9880"
|
||||
],
|
||||
"directives": [
|
||||
"HostSchemas $target"
|
||||
]
|
||||
},
|
||||
{
|
||||
"path" : "/thing",
|
||||
"upstreams": ["http://192.168.12.157:9880"],
|
||||
"directives":[
|
||||
"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 (
|
||||
"errors"
|
||||
"io/fs"
|
||||
"mime"
|
||||
"net/http"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -66,3 +67,13 @@ func FileExists(name string) (os.FileInfo, bool, error) {
|
|||
func NewFileHandler(f FileHandler) http.Handler {
|
||||
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