Giter Club home page Giter Club logo

restvoice's Introduction

restvoice's People

Contributors

tullo avatar

Stargazers

Christian Korneck avatar Andreas Gaupmann avatar Maurice Bauer avatar  avatar  avatar René Kray avatar Camal Cakar avatar

Watchers

Ralf Wirdemann avatar  avatar

Forkers

tullo rroehrig

restvoice's Issues

switch on accept header hits the default case when client specifies multiple values

In kapitel05/main.go

accept := request.Header.Get("Accept")
switch accept {
	case "application/pdf":
		content := bytes.NewReader(i.ToPDF())
		http.ServeContent(writer, request, "invoice.pdf", time.Now(), content)
	case "application/json":
		b, _ := json.Marshal(i)
		writer.Header().Set("Content-Type", "application/json")
		_, _ = writer.Write(b)
	default:
		writer.WriteHeader(http.StatusNotAcceptable)
	}

If the client sends multiple values curl -i http://localhost:8080/customers/1/invoices/1 \ -H 'Accept: application/pdf, application/json' then the switch will always hit the default case.

Value of accept is application/pdf, application/json and does not match any case.

I thought I'd mention it as the book states that query on page 65

Code Smells

The code smells mentioned in the book on page 84 are not addressed in chapter 7.

Should the aggregation block be refactored into a separate function on the usecase or the invoice domain? What is your take on that?

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.