Git Product home page Git Product logo

Comments (20)

nwidger avatar nwidger commented on May 27, 2024

Perhaps we should be using https://golang.org/pkg/mime/#ParseMediaType to parse the Content-Type header?

from wuzz.

asciimoo avatar asciimoo commented on May 27, 2024

@nwidger yap, definitely that would be the proper solution.

from wuzz.

nwidger avatar nwidger commented on May 27, 2024

@asciimoo I'll try and send a PR for that in a few.

from wuzz.

asciimoo avatar asciimoo commented on May 27, 2024

@nwidger awesome! thank you.

from wuzz.

williamn avatar williamn commented on May 27, 2024

@asciimoo thank you 👍

from wuzz.

williamn avatar williamn commented on May 27, 2024

I have tried the new code, I just find out that my endpoint return Content-Type: application/vnd.api+json; charset=utf-8 and wuzz failed to recognize it as JSON. Perhaps because of the charset? What do you think?

from wuzz.

nwidger avatar nwidger commented on May 27, 2024

@williamn I'm pretty sure mime.ParseMediaType handles parameters correctly. Here's a Playground link showing it's behavior with application/vnd.api+json; charset=utf-8:

https://play.golang.org/p/F1H0FnDFgg

Are you sure the formatJSON config option is enabled and that the JSON body being returned is properly formatted? Either of those would prevent wuzz from colorizing a JSON response despite successfully detecting it as JSON from the Content-Type.

from wuzz.

williamn avatar williamn commented on May 27, 2024

@nwidger yes, I got formatJSON = true in my ~/.wuzz/config.toml and my JSON response is valid. Is there any other way to test?

from wuzz.

nwidger avatar nwidger commented on May 27, 2024

@williamn Is there a wuzz incantation for a public API endpoint that you can provide that exhibits the bad behavior you're seeing?

from wuzz.

williamn avatar williamn commented on May 27, 2024

@nwidger I create a mock of my endpoint here http://www.mocky.io/v2/58b404b3110000c7191c4371

from wuzz.

asciimoo avatar asciimoo commented on May 27, 2024

@williamn this works well for me. wuzz http://www.mocky.io/v2/58b404b3110000c7191c4371 displays the highlighted and formatted json.

from wuzz.

williamn avatar williamn commented on May 27, 2024

@asciimoo hmm. That's strange. Here is my result

image

from wuzz.

asciimoo avatar asciimoo commented on May 27, 2024

Strange...
Here is my output of running wuzz -c /dev/null http://www.mocky.io/v2/58b404b3110000c7191c4371 (default config):
wuzz

from wuzz.

williamn avatar williamn commented on May 27, 2024

@asciimoo I tried to use wuzz -c /dev/null http://www.mocky.io/v2/58b404b3110000c7191c4371 but in my side the result is the same 😁

from wuzz.

asciimoo avatar asciimoo commented on May 27, 2024

@williamn what is your go version? i'm using go version go1.8 linux/amd64

from wuzz.

williamn avatar williamn commented on May 27, 2024

@asciimoo here is mine go version go1.7 linux/amd64

from wuzz.

nwidger avatar nwidger commented on May 27, 2024

@williamn Perhaps try building in a fresh GOPATH to rule out any stale dependencies?

mkdir ~/gotmp
GOPATH=$(realpath ~/gotmp) go get -u github.com/asciimoo/wuzz
~/gotmp/bin/wuzz -c /dev/null http://www.mocky.io/v2/58b404b3110000c7191c4371

from wuzz.

williamn avatar williamn commented on May 27, 2024

@nwidger it works! what seems to be the problem?

from wuzz.

nwidger avatar nwidger commented on May 27, 2024

@williamn If that worked then it could be a couple of things:

What does which wuzz return? If it doesn't return $GOPATH/bin/wuzz, then you've been running some other wuzz binary from an entry in your PATH environment variable. You should either delete those versions of wuzz or reorder PATH such that $GOPATH/bin is searched sooner.

It's also possible you have been running $GOPATH/bin/wuzz this entire time and simply have out of date versions of wuzz or some of its dependencies. The simplest thing would probably be to run:

rm -rf $GOPATH/src/github.com/asciimoo/wuzz
go get -u github.com/asciimoo/wuzz

and then see if $GOPATH/bin/wuzz -c /dev/null http://www.mocky.io/v2/58b404b3110000c7191c4371 works correctly.

from wuzz.

williamn avatar williamn commented on May 27, 2024

@nwidger thanks. I reinstall the package and it's fine now.

from wuzz.

Related Issues (20)

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.