-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kor server first commit: new go server in net/http, including TLS, To…
…ken, Swagger
- Loading branch information
Showing
9 changed files
with
570 additions
and
0 deletions.
There are no files selected for viewing
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,2 @@ | ||
server.crt | ||
server.key |
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,134 @@ | ||
// 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/v1/example-get": { | ||
"get": { | ||
"description": "An example GET API", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"summary": "Example GET endpoint", | ||
"parameters": [ | ||
{ | ||
"type": "string", | ||
"description": "Authorization token", | ||
"name": "Authorization", | ||
"in": "header" | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/main.response" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/api/v1/example-post": { | ||
"post": { | ||
"description": "An example POST API", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"summary": "Example POST endpoint", | ||
"parameters": [ | ||
{ | ||
"description": "Post Request Data", | ||
"name": "request", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"$ref": "#/definitions/main.postRequest" | ||
} | ||
}, | ||
{ | ||
"type": "string", | ||
"description": "Authorization token", | ||
"name": "Authorization", | ||
"in": "header" | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/main.response" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/healthcheck": { | ||
"get": { | ||
"description": "Returns the status of the server", | ||
"summary": "Health Check", | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/main.response" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"main.postRequest": { | ||
"type": "object", | ||
"properties": { | ||
"data": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"main.response": { | ||
"type": "object", | ||
"properties": { | ||
"message": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
}` | ||
|
||
// SwaggerInfo holds exported Swagger Info so clients can modify it | ||
var SwaggerInfo = &swag.Spec{ | ||
Version: "1.0", | ||
Host: "", | ||
BasePath: "", | ||
Schemes: []string{}, | ||
Title: "KOR API Swagger", | ||
Description: "KOR API Swagger", | ||
InfoInstanceName: "swagger", | ||
SwaggerTemplate: docTemplate, | ||
LeftDelim: "{{", | ||
RightDelim: "}}", | ||
} | ||
|
||
func init() { | ||
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) | ||
} |
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,108 @@ | ||
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "KOR API Swagger", | ||
"title": "KOR API Swagger", | ||
"contact": {}, | ||
"version": "1.0" | ||
}, | ||
"paths": { | ||
"/api/v1/example-get": { | ||
"get": { | ||
"description": "An example GET API", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"summary": "Example GET endpoint", | ||
"parameters": [ | ||
{ | ||
"type": "string", | ||
"description": "Authorization token", | ||
"name": "Authorization", | ||
"in": "header" | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/main.response" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/api/v1/example-post": { | ||
"post": { | ||
"description": "An example POST API", | ||
"consumes": [ | ||
"application/json" | ||
], | ||
"produces": [ | ||
"application/json" | ||
], | ||
"summary": "Example POST endpoint", | ||
"parameters": [ | ||
{ | ||
"description": "Post Request Data", | ||
"name": "request", | ||
"in": "body", | ||
"required": true, | ||
"schema": { | ||
"$ref": "#/definitions/main.postRequest" | ||
} | ||
}, | ||
{ | ||
"type": "string", | ||
"description": "Authorization token", | ||
"name": "Authorization", | ||
"in": "header" | ||
} | ||
], | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/main.response" | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"/healthcheck": { | ||
"get": { | ||
"description": "Returns the status of the server", | ||
"summary": "Health Check", | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"schema": { | ||
"$ref": "#/definitions/main.response" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"definitions": { | ||
"main.postRequest": { | ||
"type": "object", | ||
"properties": { | ||
"data": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"main.response": { | ||
"type": "object", | ||
"properties": { | ||
"message": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
} |
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,69 @@ | ||
definitions: | ||
main.postRequest: | ||
properties: | ||
data: | ||
type: string | ||
type: object | ||
main.response: | ||
properties: | ||
message: | ||
type: string | ||
type: object | ||
info: | ||
contact: {} | ||
description: KOR API Swagger | ||
title: KOR API Swagger | ||
version: "1.0" | ||
paths: | ||
/api/v1/example-get: | ||
get: | ||
consumes: | ||
- application/json | ||
description: An example GET API | ||
parameters: | ||
- description: Authorization token | ||
in: header | ||
name: Authorization | ||
type: string | ||
produces: | ||
- application/json | ||
responses: | ||
"200": | ||
description: OK | ||
schema: | ||
$ref: '#/definitions/main.response' | ||
summary: Example GET endpoint | ||
/api/v1/example-post: | ||
post: | ||
consumes: | ||
- application/json | ||
description: An example POST API | ||
parameters: | ||
- description: Post Request Data | ||
in: body | ||
name: request | ||
required: true | ||
schema: | ||
$ref: '#/definitions/main.postRequest' | ||
- description: Authorization token | ||
in: header | ||
name: Authorization | ||
type: string | ||
produces: | ||
- application/json | ||
responses: | ||
"200": | ||
description: OK | ||
schema: | ||
$ref: '#/definitions/main.response' | ||
summary: Example POST endpoint | ||
/healthcheck: | ||
get: | ||
description: Returns the status of the server | ||
responses: | ||
"200": | ||
description: OK | ||
schema: | ||
$ref: '#/definitions/main.response' | ||
summary: Health Check | ||
swagger: "2.0" |
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,25 @@ | ||
module main | ||
|
||
go 1.22.2 | ||
|
||
require ( | ||
github.com/golang-jwt/jwt/v5 v5.2.1 | ||
github.com/gorilla/mux v1.8.1 | ||
github.com/swaggo/http-swagger v1.3.4 | ||
github.com/swaggo/swag v1.16.3 | ||
) | ||
|
||
require ( | ||
github.com/KyleBanks/depth v1.2.1 // indirect | ||
github.com/go-openapi/jsonpointer v0.19.5 // indirect | ||
github.com/go-openapi/jsonreference v0.20.0 // indirect | ||
github.com/go-openapi/spec v0.20.6 // indirect | ||
github.com/go-openapi/swag v0.19.15 // indirect | ||
github.com/josharian/intern v1.0.0 // indirect | ||
github.com/mailru/easyjson v0.7.6 // indirect | ||
github.com/swaggo/files v0.0.0-20220610200504-28940afbdbfe // indirect | ||
golang.org/x/net v0.17.0 // indirect | ||
golang.org/x/sys v0.13.0 // indirect | ||
golang.org/x/tools v0.7.0 // indirect | ||
gopkg.in/yaml.v2 v2.4.0 // indirect | ||
) |
Oops, something went wrong.