This commit is contained in:
2024-04-02 22:00:33 -05:00
parent 7c52969e1b
commit 9a4023acab
6 changed files with 77 additions and 0 deletions

View File

@@ -17,6 +17,9 @@ import (
// @Produce application/json
// @Success 200 {object} model.Message "response"
// @failure 500 {object} model.Message "error"
//
// @Security Authorization
//
// @Router /jokes/dadjoke [get]
func (c *Controller) GetDadJoke(w http.ResponseWriter, r *http.Request) {
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"
// @Success 200 {object} model.Message "response"
// @failure 500 {object} model.Message "error"
//
// @Security Authorization
//
// @Router /jokes/dadjoke [post]
func (c *Controller) PostDadJoke(w http.ResponseWriter, r *http.Request) {
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"
// @Success 200 {object} model.Message "response"
// @failure 500 {object} model.Message "error"
//
// @Security Authorization
//
// @Router /jokes/dadjoke [delete]
func (c *Controller) DeleteDadJoke(w http.ResponseWriter, r *http.Request) {
contentType := r.Header.Get("Content-Type")

View File

@@ -31,6 +31,8 @@ type Response struct {
//
// @failure 400 {object} model.Message "error"
//
// @Security Authorization
//
// @Router /openai/general [get]
func (c *Controller) GeneralOpenAI(w http.ResponseWriter, r *http.Request) {
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"
// @Success 200 {object} model.Message "response"
// @failure 400 {object} model.Message "error"
//
// @Security Authorization
//
// @Router /openai/travelagent [get]
func (c *Controller) TravelAgentOpenAI(w http.ResponseWriter, r *http.Request) {
contentType := r.Header.Get("Content-Type")

View File

@@ -60,6 +60,11 @@ const docTemplate = `{
},
"/jokes/dadjoke": {
"get": {
"security": [
{
"Authorization": []
}
],
"description": "get a dad joke",
"consumes": [
"application/json"
@@ -87,6 +92,11 @@ const docTemplate = `{
}
},
"post": {
"security": [
{
"Authorization": []
}
],
"description": "create a dad joke",
"consumes": [
"application/json"
@@ -123,6 +133,11 @@ const docTemplate = `{
}
},
"delete": {
"security": [
{
"Authorization": []
}
],
"description": "create a dad joke",
"consumes": [
"application/json"
@@ -161,6 +176,11 @@ const docTemplate = `{
},
"/openai/general": {
"get": {
"security": [
{
"Authorization": []
}
],
"description": "Ask ChatGPT a general question",
"consumes": [
"application/json"
@@ -199,6 +219,11 @@ const docTemplate = `{
},
"/openai/travelagent": {
"get": {
"security": [
{
"Authorization": []
}
],
"description": "Ask ChatGPT for suggestions as if it was a travel agent",
"consumes": [
"application/json"

View File

@@ -52,6 +52,11 @@
},
"/jokes/dadjoke": {
"get": {
"security": [
{
"Authorization": []
}
],
"description": "get a dad joke",
"consumes": [
"application/json"
@@ -79,6 +84,11 @@
}
},
"post": {
"security": [
{
"Authorization": []
}
],
"description": "create a dad joke",
"consumes": [
"application/json"
@@ -115,6 +125,11 @@
}
},
"delete": {
"security": [
{
"Authorization": []
}
],
"description": "create a dad joke",
"consumes": [
"application/json"
@@ -153,6 +168,11 @@
},
"/openai/general": {
"get": {
"security": [
{
"Authorization": []
}
],
"description": "Ask ChatGPT a general question",
"consumes": [
"application/json"
@@ -191,6 +211,11 @@
},
"/openai/travelagent": {
"get": {
"security": [
{
"Authorization": []
}
],
"description": "Ask ChatGPT for suggestions as if it was a travel agent",
"consumes": [
"application/json"

View File

@@ -61,6 +61,8 @@ paths:
description: error
schema:
$ref: '#/definitions/model.Message'
security:
- Authorization: []
summary: Generate dadjoke
tags:
- DadJoke
@@ -79,6 +81,8 @@ paths:
description: error
schema:
$ref: '#/definitions/model.Message'
security:
- Authorization: []
summary: Get dadjoke
tags:
- DadJoke
@@ -103,6 +107,8 @@ paths:
description: error
schema:
$ref: '#/definitions/model.Message'
security:
- Authorization: []
summary: Generate dadjoke
tags:
- DadJoke
@@ -128,6 +134,8 @@ paths:
description: error
schema:
$ref: '#/definitions/model.Message'
security:
- Authorization: []
summary: Gerneral ChatGPT
tags:
- openai
@@ -153,6 +161,8 @@ paths:
description: error
schema:
$ref: '#/definitions/model.Message'
security:
- Authorization: []
summary: Travel Agent ChatGPT
tags:
- openai

View File

@@ -35,10 +35,13 @@ func main() {
router := http.NewServeMux()
router.HandleFunc("/swagger/*", httpSwagger.Handler())
router.HandleFunc("GET /api/health/gethealth", c.GetHealth)
router.HandleFunc("GET /api/jokes/dadjoke", c.GetDadJoke)
router.HandleFunc("POST /api/jokes/dadjoke", c.PostDadJoke)
router.HandleFunc("DELETE /api/jokes/dadjoke", c.DeleteDadJoke)
router.HandleFunc("GET /api/openai/general", c.GeneralOpenAI)
router.HandleFunc("GET /api/openai/travelagent", c.TravelAgentOpenAI)
// adminRouter := http.NewServeMux()