一个Go语言的REST API框架:Ripple

jopen 8年前

Ripple是一个简单,而且灵活的Go语言 REST API 框架。以下是一个简单的用法:

package main    import (      "./ripple"      "./controllers"      "net/http"  )    func main() {         // Build the REST application        app := ripple.NewApplication()        // Create a controller and register it. Any number of controllers      // can be registered that way.        userController := rippledemo.NewUserController()      app.RegisterController("users", userController)        // Setup the routes. The special patterns `_controller` will automatically match      // an existing controller, as defined above. Likewise, `_action` will match any       // existing action.        app.AddRoute(ripple.Route{ Pattern: ":_controller/:id/:_action" })      app.AddRoute(ripple.Route{ Pattern: ":_controller/:id/" })      app.AddRoute(ripple.Route{ Pattern: ":_controller" })        // Start the server        http.ListenAndServe(":8080", app)  }

项目主页:http://www.open-open.com/lib/view/home/1370588541832