Code Monkey home page Code Monkey logo

cloudgo's Introduction

使用Martini开发框架


使用Martini的八大理由

  •  使用极其简单.
  •  无侵入式的设计.
  •  很好的与其他的Go语言包协同使用.
  •  超赞的路径匹配和路由.
  •  模块化的设计 - 容易插入功能件,也容易将其拔出来.
  •  已有很多的中间件可以直接使用.
  •  框架内已拥有很好的开箱即用的功能支持.
  •  完全兼容http.HandlerFunc接口.

建立Martini的环境

go get github.com/go-martini/martini  

编程 web 服务程序

package server

import "github.com/go-martini/martini"

func Runserver(port string) {
  // Provides some reasonable defaults that work well for web application.
  m := martini.Classic()
  // Two handlers return something.
  m.Get("/", func() string {
    return "Hello world!"
  })
  m.Get("/hello/:name", func(params martini.Params) string {
  return "Hello " + params["name"]
})
  // Run at port.
  m.RunOnAddr(":"+port)
}  

main函数使用老师提供的(作稍微的修改)。

运行服务器

此处输入图片的描述

测试命令

此处输入图片的描述 此外接着还输出Hello testuser

压力测试

此处输入图片的描述

cloudgo's People

Contributors

thougr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.