Skip to content

Commit

Permalink
Merge branch 'act' into act-prep-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
aranyia authored Jul 9, 2024
2 parents 7c82d2e + ea105af commit 24a5f11
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
29 changes: 27 additions & 2 deletions pkg/api/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,10 +209,12 @@ func (s *Service) mountAPI() {
"GET": web.ChainHandlers(
s.contentLengthMetricMiddleware(),
s.newTracingHandler("bytes-download"),
s.actDecryptionHandler(),
web.FinalHandlerFunc(s.bytesGetHandler),
),
"HEAD": web.ChainHandlers(
s.newTracingHandler("bytes-head"),
s.actDecryptionHandler(),
web.FinalHandlerFunc(s.bytesHeadHandler),
),
})
Expand All @@ -230,8 +232,14 @@ func (s *Service) mountAPI() {
))

handle("/chunks/{address}", jsonhttp.MethodHandler{
"GET": http.HandlerFunc(s.chunkGetHandler),
"HEAD": http.HandlerFunc(s.hasChunkHandler),
"GET": web.ChainHandlers(
s.actDecryptionHandler(),
web.FinalHandlerFunc(s.chunkGetHandler),
),
"HEAD": web.ChainHandlers(
s.actDecryptionHandler(),
web.FinalHandlerFunc(s.hasChunkHandler),
),
})

handle("/soc/{owner}/{id}", jsonhttp.MethodHandler{
Expand All @@ -257,6 +265,21 @@ func (s *Service) mountAPI() {
),
})

handle("/grantee", jsonhttp.MethodHandler{
"POST": web.ChainHandlers(
web.FinalHandlerFunc(s.actCreateGranteesHandler),
),
})

handle("/grantee/{address}", jsonhttp.MethodHandler{
"GET": web.ChainHandlers(
web.FinalHandlerFunc(s.actListGranteesHandler),
),
"PATCH": web.ChainHandlers(
web.FinalHandlerFunc(s.actGrantRevokeHandler),
),
})

handle("/bzz/{address}", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
u := r.URL
u.Path += "/"
Expand All @@ -267,9 +290,11 @@ func (s *Service) mountAPI() {
"GET": web.ChainHandlers(
s.contentLengthMetricMiddleware(),
s.newTracingHandler("bzz-download"),
s.actDecryptionHandler(),
web.FinalHandlerFunc(s.bzzDownloadHandler),
),
"HEAD": web.ChainHandlers(
s.actDecryptionHandler(),
web.FinalHandlerFunc(s.bzzHeadHandler),
),
})
Expand Down
23 changes: 16 additions & 7 deletions pkg/node/devnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethersphere/bee/v2/pkg/accesscontrol"
mockAccounting "github.com/ethersphere/bee/v2/pkg/accounting/mock"
"github.com/ethersphere/bee/v2/pkg/api"
"github.com/ethersphere/bee/v2/pkg/bzz"
Expand Down Expand Up @@ -60,13 +61,14 @@ import (
)

type DevBee struct {
tracerCloser io.Closer
stateStoreCloser io.Closer
localstoreCloser io.Closer
apiCloser io.Closer
pssCloser io.Closer
errorLogWriter io.Writer
apiServer *http.Server
tracerCloser io.Closer
stateStoreCloser io.Closer
localstoreCloser io.Closer
apiCloser io.Closer
pssCloser io.Closer
accesscontrolCloser io.Closer
errorLogWriter io.Writer
apiServer *http.Server
}

type DevOptions struct {
Expand Down Expand Up @@ -188,6 +190,11 @@ func NewDevBee(logger log.Logger, o *DevOptions) (b *DevBee, err error) {
}
b.localstoreCloser = localStore

session := accesscontrol.NewDefaultSession(mockKey)
actLogic := accesscontrol.NewLogic(session)
accesscontrol := accesscontrol.NewController(actLogic)
b.accesscontrolCloser = accesscontrol

pssService := pss.New(mockKey, logger)
b.pssCloser = pssService

Expand Down Expand Up @@ -337,6 +344,7 @@ func NewDevBee(logger log.Logger, o *DevOptions) (b *DevBee, err error) {
Pss: pssService,
FeedFactory: mockFeeds,
Post: post,
AccessControl: accesscontrol,
PostageContract: postageContract,
Staking: mockStaking,
Steward: mockSteward,
Expand Down Expand Up @@ -423,6 +431,7 @@ func (b *DevBee) Shutdown() error {
}

tryClose(b.pssCloser, "pss")
tryClose(b.accesscontrolCloser, "accesscontrol")
tryClose(b.tracerCloser, "tracer")
tryClose(b.stateStoreCloser, "statestore")
tryClose(b.localstoreCloser, "localstore")
Expand Down

0 comments on commit 24a5f11

Please sign in to comment.