Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kadai4 hioki-daichi #65

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions kadai4/hioki-daichi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/omikuji-server
/coverage/
2 changes: 2 additions & 0 deletions kadai4/hioki-daichi/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
24 changes: 24 additions & 0 deletions kadai4/hioki-daichi/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOTOOL=$(GOCMD) tool
GODOCCMD=godoc
GODOCPORT=6060
BINARY_NAME=omikuji-server

all: test build
build:
$(GOBUILD) -o $(BINARY_NAME) -v
test:
$(GOTEST) ./...
cov:
$(GOTEST) ./... -race -coverprofile=coverage/c.out -covermode=atomic
$(GOTOOL) cover -html=coverage/c.out -o coverage/index.html
open coverage/index.html
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
doc:
(sleep 1; open http://localhost:$(GODOCPORT)/pkg/github.com/gopherdojo/dojo3) &
$(GODOCCMD) -http ":$(GODOCPORT)"
61 changes: 61 additions & 0 deletions kadai4/hioki-daichi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# omikuji-server

omikuji-server is a JSON API server that randomly returns fortune.

## How to try

The server side starts as follows.

```shell
$ make build
$ ./omikuji-server
```

The client side sends a request as follows.

```shell
$ curl -s localhost:8080 | jq .
{
"name": "Gopher",
"fortune": "吉"
}
```

You can change the name returned from the default "Gopher" by specifying the name parameter.

```shell
$ curl -s 'localhost:8080/?name=hioki-daichi' | jq .
{
"name": "hioki-daichi",
"fortune": "大凶"
}
```

The name can be up to 32 characters.

```shell
$ curl -s 'localhost:8080/?name=A%20name%20longer%20than%20thirty%20two%20characters' | jq .
{
"errors": [
"Name is too long (maximum is 32 characters)"
]
}
```

## How to run the test

```shell
$ make test
```

## How to read GoDoc

```shell
$ make doc
```

## How to see code coverage

```shell
$ make cov
```
Loading