douxian9010 2016-07-08 10:25
浏览 45
已采纳

Go中的Rest API-使用net / http与诸如Gorilla之类的库

I see that Go itself has a package net/http which is adequate at providing everything you need to get your own REST APIs up and running. However there are variety of frameworks, most popular may be say gorilla.

Considering that one of the main things I need to do going forward is build REST APIs which in general will access some backend storage (databases, caches etc) to perform CRUD operation, is it good to go with Go's standard library itself or should I consider using some frameworks?

Normally, people write new library or framework which solves the problem present in the existing library. But lot of the frameworks also tend to make things worse when in actual demands are simple.

So I have few questions:

  1. Is the basic library in go lang good enough to support basic to moderate functionality for REST?

  2. If I do end up using inbuilt library and tomorrow have to change it to use some framework (like gorilla) how difficult/costly that effort would be?

  3. Are frameworks really addressing the problems or just making simple problems complex?

I would be extremely grateful for someone to share his thoughts here (who has been through making this choice himself) while I research more of my own.

  • 写回答

2条回答 默认 最新

  • dstjh46606 2016-07-09 02:12
    关注

    The built-in net/http package is sufficient to build a complete REST API. However, some of the libraries can make building an API slightly easier, particularly if the REST API is complex. Changing from the built-in facilities to any decent framework is relatively straightforward - they generally accept handlers of the http.Handler type.

    In the end, though, this is an extremely situational choice. The best thing you can do is examine each available solution, contrast and compare, and build a proof of concept with the top options if you possibly can. First-hand experience will guide you best.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 求螺旋焊缝的图像处理
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi
  • ¥20 win10修改放大文本以及缩放与布局后蓝屏无法正常进入桌面
  • ¥15 itunes恢复数据最后一步发生错误
  • ¥15 关于#windows#的问题:2024年5月15日的win11更新后资源管理器没有地址栏了顶部的地址栏和文件搜索都消失了