Coder Social home page Coder Social logo

go-distribued-services's Introduction

go-distribued-services

Chapter 1: Build a JSON over HTTP Server

  • projects/proglog/internal/server/log.go

    • golang does not have Classes, but types, type pointers, and interfaces have method sets you add to using the function receiver syntax
    type Log struct{
      // ...
    }
    
    func (c *Log) Append(arg Argument) (ReturnType, error) {
      // ...
    }
    • the Append function declaration takes a Log pointer named c as the receiver and gets added to the Log pointer method set
  • (7) When building a JSON/HTTP Go server, each handler cnosists of three steps:

    1. Unmarshal the request's JSON body into a struct.
    2. Run that endpoint's logic with the request to obtain a result.
    3. Marshal and write that result to the respone. If your handlers become much more complicated than this, then you should move the code out, move request and response handling into HTTP middleware, and move business logic further down the stack.

    - **note:** what do you call this type of design violation? you should apply the same philosophy to stored procedures

Repo Appendix

alias bake=(cd )

go-distribued-services's People

Contributors

mbmcmullen27 avatar

Stargazers

 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.