diff --git a/CHANGELOG.md b/CHANGELOG.md index 09d1f08..a97b615 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.10.1 + +* updated dependencies + ## 0.10.0 * fixed concurrent data access diff --git a/README.md b/README.md index 9c012d2..0d2513d 100644 --- a/README.md +++ b/README.md @@ -52,51 +52,74 @@ WantedBy=multi-user.target ## Configuration -Shifu is configured using a single `config.json` file inside the project directory. +Shifu is configured using a single `config.json` file inside the project directory. Keys starting with `_` are comments. ```json { "dev": false, - "log_level": "info", // debug, info, warn, error + "_log_level": "debug, info, warn, error", + "log_level": "info", "server": { - "host": "localhost", // leave empty for production + "_host": "Leave empty for production", + "host": "localhost", "port": 8080, - "shutdown_time": 30, // time before the server is forcefully shut down (optional) - "write_timeout": 5, // request write timeout - "read_timeout": 5, // request read timeout + "_shutdown_time": "Time before the server is forcefully shut down (optional)", + "shutdown_time": 30, + "_write_timeout": "Request write timeout", + "write_timeout": 5, + "_read_timeout": "Request read timeout", + "read_timeout": 5, "tls_cert_file": "cert/file.pem", "tls_key_file": "key/file.pem", "hostname": "example.com", "secure_cookies": true, "cookie_domain_name": "example.com" }, + "content": { + "_provider": "git, fs", + "provider": "git", + "update_seconds": 600, + "repository": "https://..." + }, "cors": { "origins": "*", "loglevel": "info" }, - "sass": { // optional configuration to compile sass - "dir": "assets", // asset directory path - "entrypoint": "style.scss", // main sass file - "out": "static/style.css", // compiled output css file path - "out_source_map": "static/style.css.map", // css map file (optional) - "watch": true // re-compile files when changed + "_sass": "Optional configuration to compile Sass", + "sass": { + "_dir": "Asset directory path", + "dir": "assets", + "_entrypoint": "Main sass file", + "entrypoint": "style.scss", + "_out": "Compiled output CSS file path", + "out": "static/style.css", + "_out_source_map": "CSS map file (optional)", + "out_source_map": "static/style.css.map", + "_watch": "Re-compile files when changed", + "watch": true }, - "js": { // optional configuration to compile js/ts (see sass configuration for reference) + "_js": "Optional configuration to compile js/ts (see Sass configuration for reference)", + "js": { "dir": "assets", "entrypoint": "entrypoint.js", "out": "static/bundle.js", "out_source_map": "static/bundle.js.map", "watch": true }, - "analytics": { // optional analytics configuration + "_analytics": "Optional analytics configuration", + "analytics": { "provider": "pirsch", - "client_id": "...", // optional when using an access key (recommended) instead of oAuth - "client_secret": "...", // required - "subnets": [ // optional subnet configuration + "_client_id": "Optional when using an access key (recommended) instead of oAuth", + "client_id": "...", + "_client_secret": "Required", + "client_secret": "...", + "_subnets": "Optional subnet configuration", + "subnets": [ "10.1.0.0/16", "10.2.0.0/8" ], - "header": [ // optional IP header configuration + "_header": "Optional IP header configuration", + "header": [ "X-Forwarded-For", "Forwarded" ] diff --git a/go.mod b/go.mod index 6147e6e..2f92a6d 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/Masterminds/sprig/v3 v3.3.0 github.com/evanw/esbuild v0.24.0 github.com/fsnotify/fsnotify v1.8.0 - github.com/go-chi/chi/v5 v5.1.0 + github.com/go-chi/chi/v5 v5.2.0 github.com/go-chi/cors v1.2.1 github.com/gorilla/mux v1.8.1 github.com/klauspost/compress v1.17.11 @@ -29,7 +29,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/shopspring/decimal v1.4.0 // indirect github.com/spf13/cast v1.7.0 // indirect - golang.org/x/crypto v0.30.0 // indirect + golang.org/x/crypto v0.31.0 // indirect golang.org/x/sys v0.28.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 7aa0266..617fe70 100644 --- a/go.sum +++ b/go.sum @@ -36,6 +36,8 @@ github.com/go-chi/chi/v5 v5.0.12 h1:9euLV5sTrTNTRUU9POmDUvfxyj6LAABLUcEWO+JJb4s= github.com/go-chi/chi/v5 v5.0.12/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/chi/v5 v5.1.0 h1:acVI1TYaD+hhedDJ3r54HyA6sExp3HfXq7QWEEY/xMw= github.com/go-chi/chi/v5 v5.1.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= +github.com/go-chi/chi/v5 v5.2.0 h1:Aj1EtB0qR2Rdo2dG4O94RIU35w2lvQSj6BRA4+qwFL0= +github.com/go-chi/chi/v5 v5.2.0/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4= github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -110,6 +112,8 @@ golang.org/x/crypto v0.28.0 h1:GBDwsMXVQi34v5CCYUm2jkJvu4cbtru2U4TN2PSyQnw= golang.org/x/crypto v0.28.0/go.mod h1:rmgy+3RHxRZMyY0jjAJShp2zgEdOqj2AO7U0pYmeQ7U= golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= diff --git a/pkg/version.go b/pkg/version.go index 22406e5..8b0e853 100644 --- a/pkg/version.go +++ b/pkg/version.go @@ -1,7 +1,7 @@ package pkg const ( - version = "0.10.0" + version = "0.10.1" ) // Version returns the Shifu version number. diff --git a/vendor/github.com/go-chi/chi/v5/README.md b/vendor/github.com/go-chi/chi/v5/README.md index 21cbb0f..7f662ab 100644 --- a/vendor/github.com/go-chi/chi/v5/README.md +++ b/vendor/github.com/go-chi/chi/v5/README.md @@ -65,7 +65,7 @@ func main() { **REST Preview:** -Here is a little preview of how routing looks like with chi. Also take a look at the generated routing docs +Here is a little preview of what routing looks like with chi. Also take a look at the generated routing docs in JSON ([routes.json](https://github.com/go-chi/chi/blob/master/_examples/rest/routes.json)) and in Markdown ([routes.md](https://github.com/go-chi/chi/blob/master/_examples/rest/routes.md)). @@ -469,7 +469,8 @@ how setting context on a request in Go works. * Carl Jackson for https://github.com/zenazn/goji * Parts of chi's thinking comes from goji, and chi's middleware package - sources from goji. + sources from [goji](https://github.com/zenazn/goji/tree/master/web/middleware). + * Please see goji's [LICENSE](https://github.com/zenazn/goji/blob/master/LICENSE) (MIT) * Armon Dadgar for https://github.com/armon/go-radix * Contributions: [@VojtechVitek](https://github.com/VojtechVitek) diff --git a/vendor/github.com/go-chi/chi/v5/chi.go b/vendor/github.com/go-chi/chi/v5/chi.go index a1691bb..fc32c4e 100644 --- a/vendor/github.com/go-chi/chi/v5/chi.go +++ b/vendor/github.com/go-chi/chi/v5/chi.go @@ -51,7 +51,7 @@ // "/user/{name}" matches "/user/jsmith" but not "/user/jsmith/info" or "/user/jsmith/" // "/user/{name}/info" matches "/user/jsmith/info" // "/page/*" matches "/page/intro/latest" -// "/page/{other}/index" also matches "/page/intro/latest" +// "/page/{other}/latest" also matches "/page/intro/latest" // "/date/{yyyy:\\d\\d\\d\\d}/{mm:\\d\\d}/{dd:\\d\\d}" matches "/date/2017/04/01" package chi @@ -127,6 +127,10 @@ type Routes interface { // the method/path - similar to routing a http request, but without // executing the handler thereafter. Match(rctx *Context, method, path string) bool + + // Find searches the routing tree for the pattern that matches + // the method/path. + Find(rctx *Context, method, path string) string } // Middlewares type is a slice of standard middleware handlers with methods diff --git a/vendor/github.com/go-chi/chi/v5/context.go b/vendor/github.com/go-chi/chi/v5/context.go index e2cd908..aacf6ef 100644 --- a/vendor/github.com/go-chi/chi/v5/context.go +++ b/vendor/github.com/go-chi/chi/v5/context.go @@ -109,7 +109,7 @@ func (x *Context) URLParam(key string) string { // RoutePattern builds the routing pattern string for the particular // request, at the particular point during routing. This means, the value // will change throughout the execution of a request in a router. That is -// why its advised to only use this value after calling the next handler. +// why it's advised to only use this value after calling the next handler. // // For example, // @@ -121,6 +121,9 @@ func (x *Context) URLParam(key string) string { // }) // } func (x *Context) RoutePattern() string { + if x == nil { + return "" + } routePattern := strings.Join(x.RoutePatterns, "") routePattern = replaceWildcards(routePattern) if routePattern != "/" { diff --git a/vendor/github.com/go-chi/chi/v5/mux.go b/vendor/github.com/go-chi/chi/v5/mux.go index 6dc1904..91daf69 100644 --- a/vendor/github.com/go-chi/chi/v5/mux.go +++ b/vendor/github.com/go-chi/chi/v5/mux.go @@ -363,19 +363,40 @@ func (mx *Mux) Middlewares() Middlewares { // Note: the *Context state is updated during execution, so manage // the state carefully or make a NewRouteContext(). func (mx *Mux) Match(rctx *Context, method, path string) bool { + return mx.Find(rctx, method, path) != "" +} + +// Find searches the routing tree for the pattern that matches +// the method/path. +// +// Note: the *Context state is updated during execution, so manage +// the state carefully or make a NewRouteContext(). +func (mx *Mux) Find(rctx *Context, method, path string) string { m, ok := methodMap[method] if !ok { - return false + return "" } - node, _, h := mx.tree.FindRoute(rctx, m, path) + node, _, _ := mx.tree.FindRoute(rctx, m, path) + pattern := rctx.routePattern + + if node != nil { + if node.subroutes == nil { + e := node.endpoints[m] + return e.pattern + } - if node != nil && node.subroutes != nil { rctx.RoutePath = mx.nextRoutePath(rctx) - return node.subroutes.Match(rctx, method, rctx.RoutePath) + subPattern := node.subroutes.Find(rctx, method, rctx.RoutePath) + if subPattern == "" { + return "" + } + + pattern = strings.TrimSuffix(pattern, "/*") + pattern += subPattern } - return h != nil + return pattern } // NotFoundHandler returns the default Mux 404 responder whenever a route diff --git a/vendor/modules.txt b/vendor/modules.txt index ae42df6..9853c11 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -47,7 +47,7 @@ github.com/evanw/esbuild/pkg/api ## explicit; go 1.17 github.com/fsnotify/fsnotify github.com/fsnotify/fsnotify/internal -# github.com/go-chi/chi/v5 v5.1.0 +# github.com/go-chi/chi/v5 v5.2.0 ## explicit; go 1.14 github.com/go-chi/chi/v5 # github.com/go-chi/cors v1.2.1 @@ -110,7 +110,7 @@ github.com/yuin/goldmark/renderer github.com/yuin/goldmark/renderer/html github.com/yuin/goldmark/text github.com/yuin/goldmark/util -# golang.org/x/crypto v0.30.0 +# golang.org/x/crypto v0.31.0 ## explicit; go 1.20 golang.org/x/crypto/bcrypt golang.org/x/crypto/blowfish