前言

最近开始学习GO的WEB框架,IRIS号称是Go最快的后端Web框架,目前发展最快的Go Web框架。提供完整的MVC功能并且面向未来。
所以先从它开始。

github地址
https://github.com/kataras/iris
文档
https://www.studyiris.com/doc/irisDoc/Installation.html

安装

go get -u github.com/kataras/iris

编辑main.go

package main

   import "github.com/kataras/iris"

   func main() {
app := iris.Default() // Method: GET
// Resource: http://localhost:8080/
app.Handle("GET", "/", func(ctx iris.Context) {
ctx.HTML("Hello world!")
}) // same as app.Handle("GET", "/ping", [...])
// Method: GET
// Resource: http://localhost:8080/ping
app.Get("/ping", func(ctx iris.Context) {
ctx.WriteString("pong")
}) // Method: GET
// Resource: http://localhost:8080/hello
app.Get("/hello", func(ctx iris.Context) {
ctx.JSON(iris.Map{"message": "Hello iris web framework."})
}) // http://localhost:8080
// http://localhost:8080/ping
// http://localhost:8080/hello
app.Run(iris.Addr(":8080"))
}

运行

go run main.go

新打开个窗口执行 
curl http://localhost:8080 
结果 Hello world! 
或在浏览器 访问http://localhost:8080

测试 
现在对它进行简单压力测试 
系统配置 1核 1G内存 , 操作系统:CentOS 7.4 64位

ab -n  -c  http://localhost:8080/
#结果
This is ApacheBench, Version 2.3 <$Revision: $>
Copyright Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/ Benchmarking localhost (be patient)
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Completed requests
Finished requests Server Software:
Server Hostname: localhost
Server Port: Document Path: /
Document Length: bytes Concurrency Level:
Time taken for tests: 3.102 seconds
Complete requests:
Failed requests:
Write errors:
Total transferred: bytes
HTML transferred: bytes
Requests per second: 3223.45 [#/sec] (mean)
Time per request: 310.227 [ms] (mean)
Time per request: 0.310 [ms] (mean, across all concurrent requests)
Transfer rate: 402.93 [Kbytes/sec] received Connection Times (ms)
min mean[+/-sd] median max
Connect: 383.5
Processing: 325.4
Waiting: 325.5
Total: 625.5 Percentage of the requests served within a certain time (ms)
%
%
%
%
%
%
%
%
% (longest request)

go之web框架 iris的更多相关文章

  1. 彩虹女神跃长空,Go语言进阶之Go语言高性能Web框架Iris项目实战-项目入口与路由EP01

    书接上回,我们已经安装好Iris框架,并且构建好了Iris项目,同时配置了fresh自动监控项目的实时编译,万事俱备,只欠东风,彩虹女神蓄势待发.现在我们来看看Iris的基础功能,如何编写项目入口文件 ...

  2. 急如闪电快如风,彩虹女神跃长空,Go语言高性能Web框架Iris项目实战-初始化项目ep00

    在Golang Web编程的世界里,君不言高性能则已,言高性能必称Iris.彩虹女神的名号响彻寰宇.名动江湖,单论一个快字,无人能出其右,就连以简洁轻量著称于世的Gin也难以望其项背,只见彩虹女神Ir ...

  3. Win10系统下搭建Go lang开发环境更换国内源并且体验宇宙最快框架Iris

    原文转载自「刘悦的技术博客」https://v3u.cn/a_id_156 最近有同学开始尝试接触Go lang,拥抱新技术永远都会是一个好习惯,之前的一篇文章介绍了如何在Mac os系统下配置Go ...

  4. Go实战--也许最快的Go语言Web框架kataras/iris初识(basic认证、Markdown、YAML、Json)

    ris自称是Go语言中所有Web框架最快的,它的特点如下: 1.聚焦高性能 2.健壮的静态路由支持和通配符子域名支持. 3.视图系统支持超过5以上模板 4.支持定制事件的高可扩展性Websocket ...

  5. go语言,golang学习笔记2 web框架选择

    go语言,golang学习笔记2 web框架选择 用什么go web框架比较好呢?能不能推荐个中文资料多的web框架呢? beego框架用的人最多,中文资料最多 首页 - beego: 简约 & ...

  6. go语言最快最好运用最广的web框架比较(大多数人不了解的特性)

    令人敬畏的Web框架 如果你为自己设计一个小应用程序,你可能不需要一个Web框架,但如果你正在进行生产,那么你肯定需要一个,一个好的应用程序. 虽然您认为自己拥有必要的知识和经验,但您是否愿意自行编写 ...

  7. 谁是最快的Go Web框架

    根据Julien Schmidt测试框架中测试到的go web框架,在加上lion,fasthttp,一共测试了下面的web框架. default http macaron go-json-rest ...

  8. 最好的6个Go语言Web框架

    原文:Top 6 web frameworks for Go as of 2017 作者:Edward Marinescu 译者:roy 译者注:本文介绍截至目前(2017年)最好的6个Go语言Web ...

  9. 7天用Go动手写/从零实现Web框架Gee

    设计一个框架 大部分时候,我们需要实现一个 Web 应用,第一反应是应该使用哪个框架.不同的框架设计理念和提供的功能有很大的差别.比如 Python 语言的 django和flask,前者大而全,后者 ...

随机推荐

  1. 【转】DSP动态内存分配函数的使用

    DSP里的动态内存分配,其分配的内存区域在在堆(heap)中.同时DSP里动态分配内存的函数还有calloc以及reclloc.这些动态分配的内存放置在.system段的全局池或堆(heap)中.因此 ...

  2. log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironment)的解决

    报错:log4j:WARN No appenders could be found for logger (org.springframework.core.env.StandardEnvironme ...

  3. 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)- D. Delivery Delays -二分+最短路+枚举

    2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)- D. Delivery Delays -二分+最短路+枚举 ...

  4. WEB前端-搜索引擎工作原理与SEO优化

    一.搜索引擎工作原理 搜索引擎的工作分为三个阶段,即爬行,索引和检索 1.爬行  搜索引擎具有网络爬虫或蜘蛛来执行爬网,每次抓取工具访问网页时,它都会复制该网页并将其网址添加到索引中. 在“蜘蛛”抓取 ...

  5. [牛客网 -leetcode在线编程 -02] minimum-depth-of-binary-tree -树的最短深度

    题目描述 题目描述 Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along ...

  6. Python——python3的requests模块的导入

    前言 突然就要搞python,我这个心哦~ 版本 | python 3.7 步骤 配置环境变量 右击-->属性-->打开文件位置 进入到脚本目录: C:\Users\Administrat ...

  7. python实现抽样分布描述

    本次使用木东居士提供数据案例,验证数据分布等内容, 参考链接:https://www.jianshu.com/p/6522cd0f4278 #数据读取 df = pd.read_excel('C:// ...

  8. dedecms搜索下拉

    今天公司用dedecms做一个音乐站,要用到下拉标题搜索,我在本地做的一个测试结果 以下是代码部分(ps:二级栏目不用的可以删除代码,如果只调用某一个栏目或者2个栏目可以用typeid='1,2'):

  9. noi.ac #43 dp计数

    \(sol\) 状态 \[f_{i, dis_1, dis_2, dis_3, dis_4}\] 表示到了第 \(i\) 层,其中 \(dis_{1}\) 表示第一根柱子剩下的最靠上的横木到当前 \( ...

  10. 【dp】P1026 统计单词个数

    题目描述 给出一个长度不超过200200的由小写英文字母组成的字母串(约定;该字串以每行2020个字母的方式输入,且保证每行一定为2020个).要求将此字母串分成kk份(1<k \le 401& ...