Skip to content

Commit

Permalink
Add HEAD to pubsub API
Browse files Browse the repository at this point in the history
Reason: #4 (comment)
  • Loading branch information
makew0rld committed May 9, 2022
1 parent 220dc85 commit 212017c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions go-ipfs/core/corehttp/gateway_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ func (i *gatewayHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
i.pubsubGetHandler(w, r)
case http.MethodPost:
i.pubsubPostHandler(w, r)
case http.MethodHead:
i.pubsubHeadHandler(w, r)
default:
http.Error(w, "Method "+r.Method+" not allowed", http.StatusMethodNotAllowed)
}
Expand Down
5 changes: 5 additions & 0 deletions go-ipfs/core/corehttp/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const (
maxPubsubMsgSize = 1 << 20
)

func (i *gatewayHandler) pubsubHeadHandler(w http.ResponseWriter, r *http.Request) {
i.addUserHeaders(w)
w.Header().Set("X-IPFS-ID", i.id.Pretty())
}

func (i *gatewayHandler) pubsubGetHandler(w http.ResponseWriter, r *http.Request) {
topic := r.URL.Path[len("/pubsub/"):]
if topic == "" {
Expand Down

0 comments on commit 212017c

Please sign in to comment.