Git Product home page Git Product logo

crud-server-with-echo-golang's Introduction

crud-server-with-echo-golang

Document

Note

  • Tk golang nó tạo struct để dùng thay cho json object.

  • Cả body của request và body của response đều dùng struct cả.

  • Không được đặt folder, package trùng tên key word của go như: middleware, server, echo

If in golang

  • https://www.callicoder.com/golang-control-flow/#if-with-a-short-statement

  • If with a short statement:

  • An if statement in Golang can also contain a short declaration statement preceding the conditional expression

  • if n := 10; n%2 == 0 {
    fmt.Printf("%d is even\n", n)
    }
  • The variable declared in the short statement is only available inside the if block and it’s else or else-if branches

  • if n := 15; n%2 == 0 {
        fmt.Printf("%d is even\n", n)
    } else {
        fmt.Printf("%d is odd\n", n)
    }

UnMarshaling or consuming Json Data

  • The Unmarshal function provided by Go’s JSON standard library lets us parse raw JSON data in the form of []byte variables.

Marshaling or creating Json Data

  • In above code, Json.Marshal() return , finalJson as the Json string, represented as bytes, and second parameter here is the error Which should be ideally handle.

Encoding JSON : writing | creating data

Decoding JSON | Reading data

Flow chart

  1. User gọi api "/login" để đăng nhập, nó sẽ trả về cho user 1 tk json web token.

  2. User sử dụng jwt đó để goi api "/", nếu jwt hợp lệ thì mới cho đi qua

Flow chart

crud-server-with-echo-golang's People

Contributors

lephongplus2016 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.