-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bf090a9
Showing
30 changed files
with
1,952 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
root = "." | ||
testdata_dir = "testdata" | ||
tmp_dir = "tmp" | ||
watch_dir = "./" | ||
|
||
exclude_dir = ["assets", "tmp", "vendor"] | ||
|
||
|
||
[build] | ||
args_bin = [] | ||
bin = "cmd/server/tmp/main" | ||
cmd = "cd cmd/server && go build -o ./tmp/main ." | ||
delay = 0 | ||
exclude_dir = ["assets", "tmp", "vendor", "testdata"] | ||
exclude_file = [] | ||
exclude_regex = ["_test.go"] | ||
exclude_unchanged = false | ||
follow_symlink = false | ||
full_bin = "" | ||
include_dir = [] | ||
include_ext = ["go", "tpl", "tmpl", "html"] | ||
include_file = [] | ||
kill_delay = "0s" | ||
log = "build-errors.log" | ||
poll = false | ||
poll_interval = 0 | ||
rerun = false | ||
rerun_delay = 500 | ||
send_interrupt = false | ||
stop_on_error = false | ||
|
||
[color] | ||
app = "" | ||
build = "yellow" | ||
main = "magenta" | ||
runner = "green" | ||
watcher = "cyan" | ||
|
||
[log] | ||
main_only = false | ||
time = false | ||
|
||
[misc] | ||
clean_on_exit = false | ||
|
||
[screen] | ||
clear_on_rebuild = false | ||
keep_scroll = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/tmp | ||
/*/*/tmp | ||
|
||
.env | ||
/logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
FROM golang:1.21 AS build | ||
|
||
WORKDIR /app | ||
|
||
COPY go.mod ./ | ||
COPY go.sum ./ | ||
|
||
RUN go mod download | ||
|
||
COPY ./cmd/server/main.go ./cmd/server/main.go | ||
COPY ./cmd/server/docs/ ./cmd/server/docs/ | ||
COPY ./pkg/ ./pkg/ | ||
COPY ./internal/ ./internal/ | ||
COPY ./config/ ./config/ | ||
|
||
RUN CGO_ENABLED=0 go build -o ./server ./cmd/server/main.go | ||
|
||
# Stage 2 | ||
FROM alpine:latest | ||
|
||
RUN apk --no-cache add ca-certificates | ||
|
||
WORKDIR /root/ | ||
|
||
COPY --from=0 /app/server ./ | ||
COPY ./migrations/ ./migrations/ | ||
COPY .env.prod .env.prod | ||
COPY .env .env | ||
COPY ./logs/ ./logs/ | ||
|
||
EXPOSE 8080 | ||
|
||
CMD ["./server"] |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.DEFAULT_GOAL := build | ||
|
||
fmt: | ||
go fmt ./... | ||
.PHONY:fmt | ||
|
||
lint: fmt | ||
golint ./... | ||
.PHONY:lint | ||
|
||
vet: lint | ||
go vet ./... | ||
shadow ./... | ||
.PHONY:vet | ||
|
||
swag: vet | ||
swag init -d ./,../../internal | ||
.PHONY: swag | ||
|
||
build: swag | ||
go build main.go | ||
.PHONY:build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,261 @@ | ||
// Package docs Code generated by swaggo/swag. DO NOT EDIT | ||
package docs | ||
|
||
import "github.com/swaggo/swag" | ||
|
||
const docTemplate = `{ | ||
"schemes": {{ marshal .Schemes }}, | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "{{escape .Description}}", | ||
"title": "{{.Title}}", | ||
"contact": {}, | ||
"version": "{{.Version}}" | ||
}, | ||
"host": "{{.Host}}", | ||
"basePath": "{{.BasePath}}", | ||
"paths": { | ||
"/api/book/add": { | ||
"post": { | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"Books" | ||
], | ||
"summary": "Add a specific book", | ||
"parameters": [ | ||
{ | ||
"description": "Book title", | ||
"name": "title", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"description": "Book author", | ||
"name": "author", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"description": "Book coverUrl", | ||
"name": "coverUrl", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"description": "Book post url", | ||
"name": "postUrl", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/model.IDResponse" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/api/book/delete/{id}": { | ||
"delete": { | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"Books" | ||
], | ||
"summary": "Delete a specific book", | ||
"parameters": [ | ||
{ | ||
"type": "integer", | ||
"description": "Book ID", | ||
"name": "id", | ||
"in": "path", | ||
"required": true | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/model.GetBookResponse" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/api/book/update": { | ||
"patch": { | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"Books" | ||
], | ||
"summary": "Update a specific book", | ||
"parameters": [ | ||
{ | ||
"description": "Book title", | ||
"name": "title", | ||
"in": "body", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"description": "Book author", | ||
"name": "author", | ||
"in": "body", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"description": "Book coverUrl", | ||
"name": "coverUrl", | ||
"in": "body", | ||
"schema": { | ||
"type": "string" | ||
} | ||
}, | ||
{ | ||
"description": "Book post url", | ||
"name": "postUrl", | ||
"in": "body", | ||
"schema": { | ||
"type": "string" | ||
} | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/model.IDResponse" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/api/book/{id}": { | ||
"get": { | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"Books" | ||
], | ||
"summary": "Get a specific book", | ||
"parameters": [ | ||
{ | ||
"type": "integer", | ||
"description": "Book ID", | ||
"name": "id", | ||
"in": "path", | ||
"required": true | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/model.GetBookResponse" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/api/books": { | ||
"get": { | ||
"produces": [ | ||
"application/json" | ||
], | ||
"tags": [ | ||
"Books" | ||
], | ||
"summary": "Get all books", | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/model.GetBookResponse" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"model.GetBookResponse": { | ||
"type": "object", | ||
"properties": { | ||
"author": { | ||
"type": "string" | ||
}, | ||
"coverUrl": { | ||
"type": "string" | ||
}, | ||
"id": { | ||
"type": "integer" | ||
}, | ||
"postUrl": { | ||
"type": "string" | ||
}, | ||
"title": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"model.IDResponse": { | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": "integer" | ||
} | ||
} | ||
} | ||
} | ||
}` | ||
|
||
// SwaggerInfo holds exported Swagger Info so clients can modify it | ||
var SwaggerInfo = &swag.Spec{ | ||
Version: "", | ||
Host: "", | ||
BasePath: "", | ||
Schemes: []string{}, | ||
Title: "Go Rest Api", | ||
Description: "Api Endpoints for Go Server", | ||
InfoInstanceName: "swagger", | ||
SwaggerTemplate: docTemplate, | ||
LeftDelim: "{{", | ||
RightDelim: "}}", | ||
} | ||
|
||
func init() { | ||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) | ||
} |
Oops, something went wrong.