GithubHelp home page GithubHelp logo

caicloud / nirvana-practice Goto Github PK

View Code? Open in Web Editor NEW
4.0 3.0 15.0 263 KB

Get familiar with Nirvana in a practical way.

Makefile 25.26% Dockerfile 0.08% Go 72.95% Shell 1.71%
nirvana engineering framework golang

nirvana-practice's Introduction

Nirvana Practice Project

As a HTTP server framework, Nirvana is robust but can also be quite complicated. This project let you practice writing Restful APIs with Nirvana.

Prerequisites

  • Golang - the Go language
  • dep - the Go dependency management tool used by Nirvana

That is. You'll use dep to install the required Go packages.

Getting Started

The project is already runnable as it is. Use dep to install the dependencies and the Makefile to build it.

$ dep ensure -v

$ VERSION=v0.1.0 make build

Check out the help message and version information.

 $ bin/practice-server -h
Usage of bin/practice-server:
  -p, --port uint16   the HTTP port used by the server (default 8080)
  -v, --version       show version info
pflag: help requested

$ bin/nirvana-practice -v
nirvana-practice, version v0.1.0 (branch: master), revision: ab9132625bd5e2b9c8d3b2ff23c423cc9c02e9ec)

Now run the server and try the APIs.

$ bin/practice-server -p 8080

$ curl localhost:8080/api/v1alpha1/products
{"reason":"practice:NotImplemented","message":"requested feature is not implemented"}

$ curl localhost:8080/api/v1alpha1/unknown
{"reason":"Nirvana:Router:RouterNotFound","message":"can't find router"}

Do It Yourself

The product API is already defined in pkg/apis/v1alpha1/products.go for you, alone with the incomplete GET and LIST API descriptors and handlers. Try to finish the GET and LIST APIs, and write POST, LIST, PUT, and DELETE from scratch.

Use GitHub issue to ask questions and, once finished, submit a PR to this repo to show off your result.

Containerize Your App

Once your code is finished and tested, you might want to containerize your app so that you can deploy it practically. The Dockerfile is created for you under the /build directory. Try to finish it run make container to build the container images.

Check out the official Docker Getting-Started guide if you are not already familiar with Docker and containers.

nirvana-practice's People

Contributors

bbbmj avatar hezhizhen avatar lichuan0620 avatar supereagle avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 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.