Skip to content

Commit

Permalink
kor server first commit: new go server in net/http, including TLS, To…
Browse files Browse the repository at this point in the history
…ken, Swagger
  • Loading branch information
hagay3 committed Sep 5, 2024
1 parent 495c7bb commit 241d48c
Show file tree
Hide file tree
Showing 9 changed files with 570 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/kor/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
server.crt
server.key
134 changes: 134 additions & 0 deletions backend/kor/docs/docs.go
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)
}
108 changes: 108 additions & 0 deletions backend/kor/docs/swagger.json
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"
}
}
}
}
}
69 changes: 69 additions & 0 deletions backend/kor/docs/swagger.yaml
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"
25 changes: 25 additions & 0 deletions backend/kor/go.mod
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
)
Loading

0 comments on commit 241d48c

Please sign in to comment.