# Custom logic over IPFS

**URL:** <https://discuss.ipfs.tech/t/custom-logic-over-ipfs/15143>\
**Category:** Kubo\
**Tags:** go-ipfs\
**Created:** [September 9, 2022, 11:25am UTC](https://discuss.ipfs.tech/t/custom-logic-over-ipfs/15143 "2022-09-09T11:25:54Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![LvLs9](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/lvls9/32/6457_2.png) [@LvLs9](https://discuss.ipfs.tech/u/LvLs9)\
**Post date:** [September 9, 2022, 11:25am UTC](https://discuss.ipfs.tech/t/custom-logic-over-ipfs/15143/1 "2022-09-09T11:25:54Z")

</div>

Hi everyone here!

I’m planning to store my content in IPFS, but after getting content I want to use custom logic like `custom-protocol-decoding` . What is proper way to do that on **high loads**? (need to have as small network-overhead as possible)

As I understand, I can just create `custom-logic-go-app` and deploy it on same machine, so it’ll just proxy content from IPFS. But what is proper way to get content from IPFS? Should usual `GET localhost:8080/ipfs/<cid>` be enough or do I need to use p2p connection like swarm or etc?

Or should I extend `kubo` -library, add some extra logic here and build my own Custom-IPFS-Docker?

Thanks a lot, guys!

---

<div class="post-metadata">

**Author:** ![LvLs9](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/lvls9/32/6457_2.png) [@LvLs9](https://discuss.ipfs.tech/u/LvLs9)\
**Post date:** [September 9, 2022, 11:27am UTC](https://discuss.ipfs.tech/t/custom-logic-over-ipfs/15143/2 "2022-09-09T11:27:05Z")

</div>

Dear @hector I think I need your help here 🙏

---

<div class="post-metadata">

**Author:** ![hector](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/hector/32/178_2.png) [@hector](https://discuss.ipfs.tech/u/hector)\
**Post date:** [September 9, 2022, 3:26pm UTC](https://discuss.ipfs.tech/t/custom-logic-over-ipfs/15143/3 "2022-09-09T15:26:44Z")

</div>

> Should usual `GET localhost:8080/ipfs/<cid>` be enough

That would be enough I guess, depending on what you are trying to read from ipfs and for what.

---

<div class="post-metadata">

**Author:** ![LvLs9](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/lvls9/32/6457_2.png) [@LvLs9](https://discuss.ipfs.tech/u/LvLs9)\
**Post date:** [September 11, 2022, 4:06pm UTC](https://discuss.ipfs.tech/t/custom-logic-over-ipfs/15143/4 "2022-09-11T16:06:34Z")

</div>

Thanks a lot, Hector! 🤝

Could you say what should I use as transport - [net/http](https://pkg.go.dev/net/http) or [golang.org/x/net/http2](http://golang.org/x/net/http2)?

---

<div class="post-metadata">

**Author:** ![LvLs9](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/lvls9/32/6457_2.png) [@LvLs9](https://discuss.ipfs.tech/u/LvLs9)\
**Post date:** [September 12, 2022, 9:32pm UTC](https://discuss.ipfs.tech/t/custom-logic-over-ipfs/15143/5 "2022-09-12T21:32:45Z")

</div>

@hector thanks a lot again! Everything works!

net/http is enough. Btw, don’t you know why IPFS does not support http2?

---

<div class="post-metadata">

**Author:** ![Jorropo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jorropo/32/3230_2.png) [@Jorropo](https://discuss.ipfs.tech/u/Jorropo)\
**Post date:** [September 13, 2022, 5:01am UTC](https://discuss.ipfs.tech/t/custom-logic-over-ipfs/15143/6 "2022-09-13T05:01:07Z")

</div>

`net/http` imports `golang.org/x/net/http2` BTW.

---

<div class="post-metadata">

**Author:** ![Jorropo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jorropo/32/3230_2.png) [@Jorropo](https://discuss.ipfs.tech/u/Jorropo)\
**Post date:** [September 13, 2022, 5:04am UTC](https://discuss.ipfs.tech/t/custom-logic-over-ipfs/15143/7 "2022-09-13T05:04:08Z")

</div>

The default implementation of `net/http` is a bit google opinionated so it only follows google’s early drafts at http2 (you NEED encryption (TLS) to have http2 which Kubo does not ship with).

You can get http2 without tls (called `h2c`) working, ~~however doing this you do not have http1 support (so you would need two listeners, one for http and one for h2c)~~.

h2c isn’t widely support also.

Edit: nvm it seems you can do upgrades, however the lack of widespread client supports make this kidna meh

---

<div class="post-metadata">

**Author:** ![LvLs9](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/lvls9/32/6457_2.png) [@LvLs9](https://discuss.ipfs.tech/u/LvLs9)\
**Post date:** [September 13, 2022, 5:04am UTC](https://discuss.ipfs.tech/t/custom-logic-over-ipfs/15143/8 "2022-09-13T05:04:53Z")

</div>

Not sure fully understand how it works, but heard same, yes 🙂

---

<div class="post-metadata">

**Author:** ![Jorropo](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/jorropo/32/3230_2.png) [@Jorropo](https://discuss.ipfs.tech/u/Jorropo)\
**Post date:** [September 13, 2022, 5:07am UTC](https://discuss.ipfs.tech/t/custom-logic-over-ipfs/15143/9 "2022-09-13T05:07:31Z")

</div>

> **[h2c package - golang.org/x/net/http2/h2c - Go Packages](https://pkg.go.dev/golang.org/x/net/http2/h2c)**
>
> Package h2c implements the unencrypted "h2c" form of HTTP/2.

> The first request on an h2c connection is read entirely into memory before the Handler is called. To limit the memory consumed by this request, wrap the result of NewHandler in an http.MaxBytesHandler.

I was about to open a new issue on Kubo to add h2c support, but this is a deal breaker, we REALLY need to support streaming BIG requests. (a file upload can be GiBs big for example)

---

<div class="post-metadata">

**Author:** ![LvLs9](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/lvls9/32/6457_2.png) [@LvLs9](https://discuss.ipfs.tech/u/LvLs9)\
**Post date:** [September 13, 2022, 5:12am UTC](https://discuss.ipfs.tech/t/custom-logic-over-ipfs/15143/10 "2022-09-13T05:12:31Z")

</div>

Yes, fully agreed… We can try to do this 😏
