Skip to content

Commit

Permalink
Update README.md (#130)
Browse files Browse the repository at this point in the history
* Update documentation + Bump caddy version

* Edit Souin logo rendering in md
  • Loading branch information
darkweak committed Sep 5, 2021
1 parent 6884cd5 commit 2bb40c7
Show file tree
Hide file tree
Showing 11 changed files with 203 additions and 99 deletions.
219 changes: 164 additions & 55 deletions README.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions docs/img/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion plugins/caddy/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
# The Windows build currently fail because of https://github.com/golang/go/issues/40795, and because xcaddy isn't compatible with the known workaround
#os: [ ubuntu-latest, macos-latest, windows-latest ]
os: [ ubuntu-latest, macos-latest ]
go: [ '1.15' ]
go: [ '1.16', '1.17' ]

runs-on: ${{ matrix.os }}

Expand Down
6 changes: 3 additions & 3 deletions plugins/caddy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ This is a distributed HTTP cache module for Caddy based on [Souin](https://githu

* Supports most HTTP cache headers defined in [RFC 7234](https://httpwg.org/specs/rfc7234.html) (see the TODO section for limitations)
* Sets [the `Cache-Status` HTTP Response Header](https://httpwg.org/http-extensions/draft-ietf-httpbis-cache-header.html)
* REST API to be able to purge the cache and list stored keys.
* Embedded (or not) distributed cache can be used and a non-distributed one is supported too.
* REST API to purge the cache and list stored resources.
* Builtin support for distributed cache.


## Example Configurations

You can find an example for the [Caddyfile](Caddyfile) or the [JSON file](configuration.json).
See the [Souin](https://github.com/darkweak/souin) configuration for the full configuration, and his associated [Caddyfile](https://github.com/darkweak/souin/plugins/caddy/Caddyfile)
See the [Souin](https://github.com/darkweak/souin) configuration for the full configuration, and its associated [Caddyfile](https://github.com/darkweak/souin/blob/master/plugins/caddy/Caddyfile)


## TODO
Expand Down
5 changes: 3 additions & 2 deletions plugins/caddy/app.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package caddy
package httpcache

import (
"errors"
"github.com/caddyserver/caddy/v2"
"github.com/darkweak/souin/cache/types"
"github.com/darkweak/souin/configurationtypes"
Expand All @@ -26,7 +27,7 @@ func (s *SouinApp) Provision(_ caddy.Context) error {
// Start will start the App
func (s SouinApp) Start() error {
if s.DefaultCache != nil && s.DefaultCache.GetTTL() == 0 {
return new(defaultCacheError)
return errors.New("Invalid/Incomplete default cache declaration")
}
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/caddy/configuration.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package caddy
package httpcache

import (
"time"
Expand Down
7 changes: 0 additions & 7 deletions plugins/caddy/error.go

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/caddy/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/darkweak/souin/plugins/caddy
go 1.16

require (
github.com/caddyserver/caddy/v2 v2.4.4
github.com/caddyserver/caddy/v2 v2.4.5
github.com/darkweak/souin v1.5.5
go.uber.org/zap v1.19.0
)
8 changes: 4 additions & 4 deletions plugins/caddy/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ github.com/buraksezer/consistent v0.0.0-20191006190839-693edf70fd72/go.mod h1:OE
github.com/buraksezer/olric v0.3.11 h1:0WaCMBSGMhmUkFtJc8X2FnNwnXqO7jviYzD7ikZgHSQ=
github.com/buraksezer/olric v0.3.11/go.mod h1:o0fRJZTHrJJto62IApcdRd5jNkGUomTlouIEL1NGCi4=
github.com/caarlos0/ctrlc v1.0.0/go.mod h1:CdXpj4rmq0q/1Eb44M9zi2nKB0QraNKuRGYGrrHhcQw=
github.com/caddyserver/caddy/v2 v2.4.4 h1:QBsN1jXEsCqRpKPBb8ebVnBNgPxwL50HINWWTuZ7evU=
github.com/caddyserver/caddy/v2 v2.4.4/go.mod h1:cZwYh3+kDWw5v/ePDTyXPeAsC8J+6sROPk3sNFObE/g=
github.com/caddyserver/certmagic v0.14.4 h1:jlGiMUHOd7p3sgT8zHA/4wckZjIp/6ME2JWGAN5zh5E=
github.com/caddyserver/certmagic v0.14.4/go.mod h1:/0VQ5og2Jxa5yBQ8eT80wWS7fi/DgNy1uXeXRUJ1Wj0=
github.com/caddyserver/caddy/v2 v2.4.5 h1:P1mRs6V2cMcagSPn+NWpD+OEYUYLIf6ecOa48cFGeUg=
github.com/caddyserver/caddy/v2 v2.4.5/go.mod h1:YhfZAAh3jWSbG6rEEOM49FwxmcbLY2fZQVlo59Sc/80=
github.com/caddyserver/certmagic v0.14.5 h1:y4HcFzLLBMsTv8sSlAPj5K55mvntX8e8ExcmB/lhO6w=
github.com/caddyserver/certmagic v0.14.5/go.mod h1:/0VQ5og2Jxa5yBQ8eT80wWS7fi/DgNy1uXeXRUJ1Wj0=
github.com/campoy/unique v0.0.0-20180121183637-88950e537e7e/go.mod h1:9IOqJGCPMSc6E5ydlp5NIonxObaeu/Iub/X03EKPVYo=
github.com/casbin/casbin/v2 v2.1.2/go.mod h1:YcPU1XXisHhLzuxH9coDNf2FbKpjGlbCg3n9yuLkIJQ=
github.com/cavaliercoder/go-cpio v0.0.0-20180626203310-925f9528c45e/go.mod h1:oDpT4efm8tSYHXV5tHSdRvBet/b/QzxZ+XyyPehvm3A=
Expand Down
41 changes: 21 additions & 20 deletions plugins/caddy/main.go → plugins/caddy/httpcache.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package caddy
package httpcache

import (
"bytes"
Expand Down Expand Up @@ -145,25 +145,26 @@ func (s *SouinCaddyPlugin) FromApp(app *SouinApp) error {
Headers: app.Headers,
TTL: app.TTL,
}
} else {
dc := s.Configuration.DefaultCache
appDc := app.DefaultCache
if dc.Headers == nil {
s.Configuration.DefaultCache.Headers = appDc.Headers
}
if dc.TTL.Duration == 0 {
s.Configuration.DefaultCache.TTL = appDc.TTL
}
if dc.Olric.URL == "" || dc.Olric.Path == "" || dc.Olric.Configuration == nil {
s.Configuration.DefaultCache.Distributed = appDc.Distributed
s.Configuration.DefaultCache.Olric = appDc.Olric
}
if dc.Badger.Path == "" || dc.Badger.Configuration == nil {
s.Configuration.DefaultCache.Badger = appDc.Badger
}
if dc.Regex.Exclude == "" {
s.Configuration.DefaultCache.Regex.Exclude = appDc.Regex.Exclude
}
return nil
}

dc := s.Configuration.DefaultCache
appDc := app.DefaultCache
if dc.Headers == nil {
s.Configuration.DefaultCache.Headers = appDc.Headers
}
if dc.TTL.Duration == 0 {
s.Configuration.DefaultCache.TTL = appDc.TTL
}
if dc.Olric.URL == "" || dc.Olric.Path == "" || dc.Olric.Configuration == nil {
s.Configuration.DefaultCache.Distributed = appDc.Distributed
s.Configuration.DefaultCache.Olric = appDc.Olric
}
if dc.Badger.Path == "" || dc.Badger.Configuration == nil {
s.Configuration.DefaultCache.Badger = appDc.Badger
}
if dc.Regex.Exclude == "" {
s.Configuration.DefaultCache.Regex.Exclude = appDc.Regex.Exclude
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion plugins/traefik/traefik.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ api:
insecure: true

pilot:
token: 75223eaf-380a-4c16-840d-2b3ee4a2765a
token: 1050f8a0-eb6f-4458-97ae-6d223afbefe6

experimental:
localPlugins:
Expand Down

0 comments on commit 2bb40c7

Please sign in to comment.