update
This commit is contained in:
@@ -17,6 +17,9 @@ import (
|
|||||||
// @Produce application/json
|
// @Produce application/json
|
||||||
// @Success 200 {object} model.Message "response"
|
// @Success 200 {object} model.Message "response"
|
||||||
// @failure 500 {object} model.Message "error"
|
// @failure 500 {object} model.Message "error"
|
||||||
|
//
|
||||||
|
// @Security Authorization
|
||||||
|
//
|
||||||
// @Router /jokes/dadjoke [get]
|
// @Router /jokes/dadjoke [get]
|
||||||
func (c *Controller) GetDadJoke(w http.ResponseWriter, r *http.Request) {
|
func (c *Controller) GetDadJoke(w http.ResponseWriter, r *http.Request) {
|
||||||
joke, err := service.GetRandomDadJoke(c.Db.DB)
|
joke, err := service.GetRandomDadJoke(c.Db.DB)
|
||||||
@@ -44,6 +47,9 @@ func (c *Controller) GetDadJoke(w http.ResponseWriter, r *http.Request) {
|
|||||||
// @Param joke query string true "Dad Joke you wish to enter into database"
|
// @Param joke query string true "Dad Joke you wish to enter into database"
|
||||||
// @Success 200 {object} model.Message "response"
|
// @Success 200 {object} model.Message "response"
|
||||||
// @failure 500 {object} model.Message "error"
|
// @failure 500 {object} model.Message "error"
|
||||||
|
//
|
||||||
|
// @Security Authorization
|
||||||
|
//
|
||||||
// @Router /jokes/dadjoke [post]
|
// @Router /jokes/dadjoke [post]
|
||||||
func (c *Controller) PostDadJoke(w http.ResponseWriter, r *http.Request) {
|
func (c *Controller) PostDadJoke(w http.ResponseWriter, r *http.Request) {
|
||||||
contentType := r.Header.Get("Content-Type")
|
contentType := r.Header.Get("Content-Type")
|
||||||
@@ -86,6 +92,9 @@ func (c *Controller) PostDadJoke(w http.ResponseWriter, r *http.Request) {
|
|||||||
// @Param joke query string true "Dad joke you wish to delete from the database"
|
// @Param joke query string true "Dad joke you wish to delete from the database"
|
||||||
// @Success 200 {object} model.Message "response"
|
// @Success 200 {object} model.Message "response"
|
||||||
// @failure 500 {object} model.Message "error"
|
// @failure 500 {object} model.Message "error"
|
||||||
|
//
|
||||||
|
// @Security Authorization
|
||||||
|
//
|
||||||
// @Router /jokes/dadjoke [delete]
|
// @Router /jokes/dadjoke [delete]
|
||||||
func (c *Controller) DeleteDadJoke(w http.ResponseWriter, r *http.Request) {
|
func (c *Controller) DeleteDadJoke(w http.ResponseWriter, r *http.Request) {
|
||||||
contentType := r.Header.Get("Content-Type")
|
contentType := r.Header.Get("Content-Type")
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ type Response struct {
|
|||||||
//
|
//
|
||||||
// @failure 400 {object} model.Message "error"
|
// @failure 400 {object} model.Message "error"
|
||||||
//
|
//
|
||||||
|
// @Security Authorization
|
||||||
|
//
|
||||||
// @Router /openai/general [get]
|
// @Router /openai/general [get]
|
||||||
func (c *Controller) GeneralOpenAI(w http.ResponseWriter, r *http.Request) {
|
func (c *Controller) GeneralOpenAI(w http.ResponseWriter, r *http.Request) {
|
||||||
contentType := r.Header.Get("Content-Type")
|
contentType := r.Header.Get("Content-Type")
|
||||||
@@ -73,6 +75,9 @@ func (c *Controller) GeneralOpenAI(w http.ResponseWriter, r *http.Request) {
|
|||||||
// @Param message query string true "Ask ChatGPT for suggestions as a travel agent"
|
// @Param message query string true "Ask ChatGPT for suggestions as a travel agent"
|
||||||
// @Success 200 {object} model.Message "response"
|
// @Success 200 {object} model.Message "response"
|
||||||
// @failure 400 {object} model.Message "error"
|
// @failure 400 {object} model.Message "error"
|
||||||
|
//
|
||||||
|
// @Security Authorization
|
||||||
|
//
|
||||||
// @Router /openai/travelagent [get]
|
// @Router /openai/travelagent [get]
|
||||||
func (c *Controller) TravelAgentOpenAI(w http.ResponseWriter, r *http.Request) {
|
func (c *Controller) TravelAgentOpenAI(w http.ResponseWriter, r *http.Request) {
|
||||||
contentType := r.Header.Get("Content-Type")
|
contentType := r.Header.Get("Content-Type")
|
||||||
|
|||||||
25
docs/docs.go
25
docs/docs.go
@@ -60,6 +60,11 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"/jokes/dadjoke": {
|
"/jokes/dadjoke": {
|
||||||
"get": {
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Authorization": []
|
||||||
|
}
|
||||||
|
],
|
||||||
"description": "get a dad joke",
|
"description": "get a dad joke",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
@@ -87,6 +92,11 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"post": {
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Authorization": []
|
||||||
|
}
|
||||||
|
],
|
||||||
"description": "create a dad joke",
|
"description": "create a dad joke",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
@@ -123,6 +133,11 @@ const docTemplate = `{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Authorization": []
|
||||||
|
}
|
||||||
|
],
|
||||||
"description": "create a dad joke",
|
"description": "create a dad joke",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
@@ -161,6 +176,11 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"/openai/general": {
|
"/openai/general": {
|
||||||
"get": {
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Authorization": []
|
||||||
|
}
|
||||||
|
],
|
||||||
"description": "Ask ChatGPT a general question",
|
"description": "Ask ChatGPT a general question",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
@@ -199,6 +219,11 @@ const docTemplate = `{
|
|||||||
},
|
},
|
||||||
"/openai/travelagent": {
|
"/openai/travelagent": {
|
||||||
"get": {
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Authorization": []
|
||||||
|
}
|
||||||
|
],
|
||||||
"description": "Ask ChatGPT for suggestions as if it was a travel agent",
|
"description": "Ask ChatGPT for suggestions as if it was a travel agent",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
|
|||||||
@@ -52,6 +52,11 @@
|
|||||||
},
|
},
|
||||||
"/jokes/dadjoke": {
|
"/jokes/dadjoke": {
|
||||||
"get": {
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Authorization": []
|
||||||
|
}
|
||||||
|
],
|
||||||
"description": "get a dad joke",
|
"description": "get a dad joke",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
@@ -79,6 +84,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"post": {
|
"post": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Authorization": []
|
||||||
|
}
|
||||||
|
],
|
||||||
"description": "create a dad joke",
|
"description": "create a dad joke",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
@@ -115,6 +125,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"delete": {
|
"delete": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Authorization": []
|
||||||
|
}
|
||||||
|
],
|
||||||
"description": "create a dad joke",
|
"description": "create a dad joke",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
@@ -153,6 +168,11 @@
|
|||||||
},
|
},
|
||||||
"/openai/general": {
|
"/openai/general": {
|
||||||
"get": {
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Authorization": []
|
||||||
|
}
|
||||||
|
],
|
||||||
"description": "Ask ChatGPT a general question",
|
"description": "Ask ChatGPT a general question",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
@@ -191,6 +211,11 @@
|
|||||||
},
|
},
|
||||||
"/openai/travelagent": {
|
"/openai/travelagent": {
|
||||||
"get": {
|
"get": {
|
||||||
|
"security": [
|
||||||
|
{
|
||||||
|
"Authorization": []
|
||||||
|
}
|
||||||
|
],
|
||||||
"description": "Ask ChatGPT for suggestions as if it was a travel agent",
|
"description": "Ask ChatGPT for suggestions as if it was a travel agent",
|
||||||
"consumes": [
|
"consumes": [
|
||||||
"application/json"
|
"application/json"
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ paths:
|
|||||||
description: error
|
description: error
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/model.Message'
|
$ref: '#/definitions/model.Message'
|
||||||
|
security:
|
||||||
|
- Authorization: []
|
||||||
summary: Generate dadjoke
|
summary: Generate dadjoke
|
||||||
tags:
|
tags:
|
||||||
- DadJoke
|
- DadJoke
|
||||||
@@ -79,6 +81,8 @@ paths:
|
|||||||
description: error
|
description: error
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/model.Message'
|
$ref: '#/definitions/model.Message'
|
||||||
|
security:
|
||||||
|
- Authorization: []
|
||||||
summary: Get dadjoke
|
summary: Get dadjoke
|
||||||
tags:
|
tags:
|
||||||
- DadJoke
|
- DadJoke
|
||||||
@@ -103,6 +107,8 @@ paths:
|
|||||||
description: error
|
description: error
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/model.Message'
|
$ref: '#/definitions/model.Message'
|
||||||
|
security:
|
||||||
|
- Authorization: []
|
||||||
summary: Generate dadjoke
|
summary: Generate dadjoke
|
||||||
tags:
|
tags:
|
||||||
- DadJoke
|
- DadJoke
|
||||||
@@ -128,6 +134,8 @@ paths:
|
|||||||
description: error
|
description: error
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/model.Message'
|
$ref: '#/definitions/model.Message'
|
||||||
|
security:
|
||||||
|
- Authorization: []
|
||||||
summary: Gerneral ChatGPT
|
summary: Gerneral ChatGPT
|
||||||
tags:
|
tags:
|
||||||
- openai
|
- openai
|
||||||
@@ -153,6 +161,8 @@ paths:
|
|||||||
description: error
|
description: error
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/definitions/model.Message'
|
$ref: '#/definitions/model.Message'
|
||||||
|
security:
|
||||||
|
- Authorization: []
|
||||||
summary: Travel Agent ChatGPT
|
summary: Travel Agent ChatGPT
|
||||||
tags:
|
tags:
|
||||||
- openai
|
- openai
|
||||||
|
|||||||
3
main.go
3
main.go
@@ -35,10 +35,13 @@ func main() {
|
|||||||
|
|
||||||
router := http.NewServeMux()
|
router := http.NewServeMux()
|
||||||
router.HandleFunc("/swagger/*", httpSwagger.Handler())
|
router.HandleFunc("/swagger/*", httpSwagger.Handler())
|
||||||
|
|
||||||
router.HandleFunc("GET /api/health/gethealth", c.GetHealth)
|
router.HandleFunc("GET /api/health/gethealth", c.GetHealth)
|
||||||
|
|
||||||
router.HandleFunc("GET /api/jokes/dadjoke", c.GetDadJoke)
|
router.HandleFunc("GET /api/jokes/dadjoke", c.GetDadJoke)
|
||||||
router.HandleFunc("POST /api/jokes/dadjoke", c.PostDadJoke)
|
router.HandleFunc("POST /api/jokes/dadjoke", c.PostDadJoke)
|
||||||
router.HandleFunc("DELETE /api/jokes/dadjoke", c.DeleteDadJoke)
|
router.HandleFunc("DELETE /api/jokes/dadjoke", c.DeleteDadJoke)
|
||||||
|
|
||||||
router.HandleFunc("GET /api/openai/general", c.GeneralOpenAI)
|
router.HandleFunc("GET /api/openai/general", c.GeneralOpenAI)
|
||||||
router.HandleFunc("GET /api/openai/travelagent", c.TravelAgentOpenAI)
|
router.HandleFunc("GET /api/openai/travelagent", c.TravelAgentOpenAI)
|
||||||
// adminRouter := http.NewServeMux()
|
// adminRouter := http.NewServeMux()
|
||||||
|
|||||||
Reference in New Issue
Block a user