Skip to content

Commit

Permalink
add server directory
Browse files Browse the repository at this point in the history
  • Loading branch information
fmhr committed Sep 21, 2023
1 parent 324f363 commit 8ed0bb0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ BINARIES=$(BUILD_DIR)/$(BINARY_NAME)
CMD_DIR=./cmd/fj
GO_FILES:= $(shell find . -name '*.go' -type f)

# server
SERVER_BINARY=fj-server
SERVER_DIR=./cmd/server

all: build

# ビルドタスク
Expand All @@ -16,17 +20,18 @@ $(BINARIES): $(GO_FILES)

# 実行ファイルのクリーンアップ
clean:
@echo "Cleaning up..."
rm -rf $(BUILD_DIR)

# 依存関係のダウンロード
deps:
@echo "Downloading dependencies..."
go mod download

# テストタスク
test:
@echo "Running tests..."
go test -v ./...


server: $(SERVER_BINARY)

$(SERVER_BINARY): $(GO_FILES)
go build -o $(BUILD_DIR)/$(SERVER_BINARY) $(SERVER_DIR)
File renamed without changes.
16 changes: 16 additions & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package main

import (
"log"
"net/http"
)

func main() {
log.Println("starting server...")
http.HandleFunc("/", handler)
}

func handler(w http.ResponseWriter, r *http.Request) {
log.Println("handling request...")
w.Write([]byte("hello"))
}

0 comments on commit 8ed0bb0

Please sign in to comment.