Code Monkey home page Code Monkey logo

microservice's Introduction

MicroService

This is a learning project for frontend and backend development. The project is aimed to build a http server, including frontend(html/css/js) and backend(golang). No tools like tomcat or nginx will be used in this project, thus, the golang will implement all the work.

The function is similar to an opms system. Firstly, we hope to build a mini system, including basic CRUD operation, user management and permission management; Secondly, the Event Sourcing pattern is going to be used in our database; Thirdly, we will build an frontend system similar to the beego case http://opms.demo.milu365.cn/. Finally, we need to expand this system to tango, which is the framework used in our project.

backend

Gorilla

A powerful URL router and dispatcher for golang.

Basic usage

# router of gorilla tool chain
r := mux.NewRouter()
r.HandleFunc("/products/{key}", ProductHandler)
r.HandleFunc("/articles/{category}/", ArticlesCategoryHandler)
r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)

func ArticlesCategoryHandler(w http.ResponseWriter, r *http.Request) {
	vars := mux.Vars(r)
	w.WriteHeader(http.StatusOK)
	fmt.Fprintf(w, "Category: %v\n", vars["category"])
}

Router

r := mux.NewRouter()
s := r.Host("www.example.com").Subrouter()
s.HandleFunc("/products/", ProductsHandler)
s.HandleFunc("/products/{key}", ProductHandler)
s.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)

frontend

Basic Demo

The basic jquery framework is used in our micro service.

<html>
<head>
    <link rel="stylesheet" href="css/main.css" />
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js">
    </script>
    <script src="js/hello.js"> </script>
</head>

<body>
    Sampple Go Applications! <br/>
    <div>
        <p class="greeting-id"> The ID is </p>
        <p class="greeting-content"> The content is </p>
    </div>
</body>
</html>
  • the above code <script src="js/hello.js"> </script> cannot be changed to <script src="js/hello.js" />
// ajax refresh local data
$(document).ready(function() {
    $.ajax({
        url:"/api/test"
    }).then(function(data) {
        $('.greeting-id').append(data.id);
        $('.greeting-content').append(data.content);
    })
})

User

microservice's People

Contributors

sencoder avatar

Watchers

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