Skip to content

Commit f9df44f

Browse files
committed
Merge branch 'release/1.0.1'
2 parents f5bc6d2 + 08441e7 commit f9df44f

File tree

7 files changed

+100
-64
lines changed

7 files changed

+100
-64
lines changed

.circleci/config.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Golang CircleCI 2.0 configuration file
2+
#
3+
# Check https://circleci.com/docs/2.0/language-go/ for more details
4+
version: 2
5+
jobs:
6+
build:
7+
docker:
8+
# specify the version
9+
- image: circleci/golang:1.8
10+
working_directory: /go/src/github.com/classmethod/aurl
11+
steps:
12+
- checkout
13+
- run: curl https://glide.sh/get | sh
14+
- run: make deps
15+
- run: make
16+
- run:
17+
name: Running test code
18+
command: make test

Makefile

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
GOFILES := $(shell find . -name '*.go' -not -path './vendor/*')
2+
GOPACKAGES := $(shell go list ./... | grep -v /vendor/)
3+
NAME := aurl
4+
DIST_DIRS := find * - type d -exec
5+
6+
7+
.DEFAULT_GOAL := bin/$(NAME)
8+
bin/$(NAME): $(GOFILES)
9+
go build -o bin/$(NAME)
10+
11+
.PHONY: clean
12+
clean:
13+
rm -rf vendor
14+
rm -rf bin/*
15+
rm -rf dist/*
16+
17+
.PHONY: cross-build
18+
cross-build:
19+
for os in darwin linux windows; do \
20+
for arch in amd64 386; do \
21+
GOOS=$$os GOARCH=$$arch CGO_ENABLED=0 go build -o dist/$(NAME)-$$os-$$arch; \
22+
done; \
23+
done
24+
25+
.PHONY: deps
26+
deps: glide
27+
glide install
28+
29+
.PHONY: dist
30+
dist:
31+
cd dist && \
32+
$(DIST_DIRS) cp ../LICENSE {} \; && \
33+
$(DIST_DIRS) cp ../README.md {} \; && \
34+
$(DIST_DIRS) tar -zcf $(NAME)-$(VERSION)-{}.tar.gz {} \; && \
35+
$(DIST_DIRS) zip -r $(NAME)-$(VERSION)-{}.zip {} \; && \
36+
cd ..
37+
38+
.PHONY: build
39+
build:
40+
go build $(LDFLAGS) -o bin/$(NAME)
41+
42+
.PHONY: glide
43+
glide:
44+
ifeq ($(shell command -v glide 2> /dev/null),)
45+
curl https://glide.sh/get | sh
46+
endif
47+
48+
.PHONY: install
49+
install:
50+
go install $(LDFLAGS)
51+
52+
test:
53+
go test -v $(GOPACKAGES)

README.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
aurl
22
====
33

4+
[![CircleCI](https://img.shields.io/circleci/project/github/classmethod/aurl.svg)](https://circleci.com/gh/classmethod/aurl)
5+
[![License](https://img.shields.io/github/license/classmethod/aurl.svg)](https://github.com/classmethod/aurl/blob/master/LICENSE)
6+
47
## Description
58

69
HTTP CLI client with OAuth 2.0 authentication.
710

8-
You know `curl` is powerful command line tool and you can make any complex HTTP request to every servers. But the target web server is secured by OAuth 2.0, you must send another HTTP request to the authorization server before making principal request. And more, you should to manage issued access tokens for every resources.
11+
You know `curl` is powerful command line tool and you can make any complex HTTP request to every servers.
12+
But the target web server is secured by OAuth 2.0, you must send another HTTP request to the authorization server
13+
before making principal request. And more, you should to manage issued access tokens for every resources.
914

1015
`aurl` is a command-line tool that process OAuth 2.0 dance and manage access/refresh tokens automatically.
1116

@@ -160,6 +165,22 @@ $ aurl --no-print-body --print-headers -X OPTIONS http://api.example.com/path/to
160165
1. Run `gofmt -s`
161166
1. Create new Pull Request
162167

168+
## Build
169+
170+
```bash
171+
$ make deps
172+
$ make
173+
$ bin/aurl --help
174+
usage: aurl [<flags>] <url>
175+
176+
Command line utility to make HTTP request with OAuth2.
177+
178+
Flags:
179+
-h, --help Show context-sensitive help (also try --help-long and --help-man).
180+
...
181+
```
182+
183+
163184
## Author
164185

165-
[Daisuke Miyamoto](https://github.com/dai0304)
186+
[Daisuke Miyamoto](https://github.com/dai0304)

request/oauth2.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,13 @@ func tokenRequest(v url.Values,request *AurlExecution) (*string, error) {
106106
return nil, err
107107
}
108108
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
109+
req.Header.Add("Accept", "application/json")
109110
req.SetBasicAuth(request.Profile.ClientId, request.Profile.ClientSecret)
110111

111112
if dumpReq, err := httputil.DumpRequestOut(req, true); err == nil {
112113
log.Printf("Token request >>>\n%s\n<<<", string(dumpReq))
113114
} else {
114-
log.Printf("Token request dump failed: ", err)
115+
log.Printf("Token request dump failed: %s", err)
115116
}
116117

117118
client := &http.Client{
@@ -122,16 +123,17 @@ func tokenRequest(v url.Values,request *AurlExecution) (*string, error) {
122123
},
123124
}
124125
resp, err := client.Do(req)
125-
defer resp.Body.Close()
126126
if err != nil {
127127
log.Printf("Token request failed: %s", err.Error())
128128
return nil, err
129129
}
130130

131+
defer resp.Body.Close()
132+
131133
if dumpResp, err := httputil.DumpResponse(resp, true); err == nil {
132134
log.Printf("Token response >>>\n%s\n<<<", string(dumpResp))
133135
} else {
134-
log.Printf("Token response dump failed: ", err)
136+
log.Printf("Token response dump failed: %s", err)
135137
}
136138

137139
if resp.StatusCode == 200 {

scripts/compile.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

scripts/package.sh

Lines changed: 0 additions & 45 deletions
This file was deleted.

version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package main
22

33
const Name string = "aurl"
4-
const Version string = "1.0"
4+
const Version string = "1.0.1"
55
const Author string = "Daisuke Miyamoto <[email protected]>"

0 commit comments

Comments
 (0)