Comments (20)
Perhaps we should be using https://golang.org/pkg/mime/#ParseMediaType to parse the Content-Type header?
from wuzz.
@nwidger yap, definitely that would be the proper solution.
from wuzz.
@asciimoo I'll try and send a PR for that in a few.
from wuzz.
@nwidger awesome! thank you.
from wuzz.
@asciimoo thank you 👍
from wuzz.
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.
@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.
@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.
@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.
@nwidger I create a mock of my endpoint here http://www.mocky.io/v2/58b404b3110000c7191c4371
from wuzz.
@williamn this works well for me. wuzz http://www.mocky.io/v2/58b404b3110000c7191c4371
displays the highlighted and formatted json.
from wuzz.
@asciimoo hmm. That's strange. Here is my result
from wuzz.
Strange...
Here is my output of running wuzz -c /dev/null http://www.mocky.io/v2/58b404b3110000c7191c4371
(default config):
from wuzz.
@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.
@williamn what is your go version? i'm using go version go1.8 linux/amd64
from wuzz.
@asciimoo here is mine go version go1.7 linux/amd64
from wuzz.
@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.
@nwidger it works! what seems to be the problem?
from wuzz.
@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.
@nwidger thanks. I reinstall the package and it's fine now.
from wuzz.
Related Issues (20)
- Add to homebrew HOT 2
- Request data missing when loading request from file HOT 1
- Simplified Chinese support error HOT 3
- Press F1 for help does not work. HOT 2
- Any way to set a default path to save/load request ? HOT 1
- Can we save all request into single file? HOT 1
- Can't run wuzz anymore. Fails with 'Error! Unknown command: redirects' HOT 1
- adding new shorcut which does clear all tabs in once
- Paste insert spaces between characters HOT 3
- Unrecognized import path HOT 1
- termbox: unsupported terminal with tmux HOT 4
- Quick question on JSON ouput HOT 4
- undefined: strings.ReplaceAll for go 1.10.x HOT 3
- Request data not saved in history HOT 7
- Missing vim keybinds in history/help
- Excess characters appear when saving input after using Ctrl O HOT 2
- Undefined error with unix.IoctlGetTermios when doing "go get" HOT 3
- Cannot build wuzz with go 1.18 HOT 1
- Please add cursor support for editing
- Please bump golang.org/x/sys dependency to enable build on riscv64-freebsd
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wuzz.