Giter Site home page Giter Site logo

crema's Introduction

Crema

Crema is a Simple Go-Based RESTful API Framework originally written by Universitas Pertamina ICT teams to support its Microservices environment development. It is written in pure Go and completely free. Crema is now maintained by a small independent research and development team, and is also supported by Hexavara Foundation.

RESTful

Playing with RESTful API using Crema is fun and easy

  • Create HTTP routes
func main() {
	server := crema.InitServer()

	server.AddRoutes(http.MethodGet, "/hello", hello)
	server.AddRoutes(http.MethodGet, "/users", crema.MakeGenericGetHandler(getUser))
  
	crema.LogPrintf("[MAIN] Server is running, listening to port 8001 ....")

	log.Fatal(http.ListenAndServe(":8001", server.Router))
}
  • Create Handlers
func hello(w http.ResponseWriter, r *http.Request) {
	w.Write([]byte("Hello World!"))
}

func getUser(conditions map[string]string) (*sql.Rows, error) {
	q := crema.Select().All().From("users")

	return crema.ExecuteQuery(q.QueryString)
}
  • Try it using cURL
$ curl http://localhost:8001/hello
Hello World!

$ curl http://localhost:8001/users
{"status":1,"message":"Success 200","data":[{"email":"[email protected]","id":16,"name":"John Doe"},{"email":"[email protected]","id":17,"name":"Bob"}]}

What's Inside

  • A Gorilla Mux-based HTTP router
  • Customizable generic request handler
  • Simplified Data Access Object mechanism
  • PostgreSQL and MySQL database driver
  • Personalized system logger

Installation

  1. With a correctly configured Go toolchain:
$ go get github.com/gadp22/crema
  1. Import in your code
import "github.com/gadp22/crema"

Examples and Tutorials

How to set up your first project using Crema.

See here to see basic example to build a CRUD API.

See here to see further documentations.

crema's People

Contributors

gadp22 avatar osucarus avatar burhanbur avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  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.