Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
caddyproxy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
caddyproxy
Commits
44421f0d
Commit
44421f0d
authored
Sep 30, 2024
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug
parent
464dc2bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
6 deletions
+11
-6
run.go
command/run/run.go
+4
-1
server.go
openapi/server.go
+7
-5
No files found.
command/run/run.go
View file @
44421f0d
...
@@ -3,6 +3,7 @@ package run
...
@@ -3,6 +3,7 @@ package run
import
(
import
(
log
"github.com/sirupsen/logrus"
log
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/cobra"
"github.com/xueqianlu/caddyproxy/caddy"
"github.com/xueqianlu/caddyproxy/openapi"
"github.com/xueqianlu/caddyproxy/openapi"
"os"
"os"
)
)
...
@@ -90,11 +91,13 @@ func runCommand(cmd *cobra.Command, _ []string) {
...
@@ -90,11 +91,13 @@ func runCommand(cmd *cobra.Command, _ []string) {
}
}
}()
}()
capi
:=
caddy
.
NewCaddyAPI
(
params
.
caddyUrl
,
params
.
caddyRoot
)
api
:=
openapi
.
NewOpenAPI
(
&
openapi
.
Config
{
api
:=
openapi
.
NewOpenAPI
(
&
openapi
.
Config
{
Host
:
params
.
host
,
Host
:
params
.
host
,
Port
:
params
.
port
,
Port
:
params
.
port
,
TempDir
:
params
.
downloadDir
,
TempDir
:
params
.
downloadDir
,
})
}
,
capi
)
if
err
:=
api
.
Run
();
err
!=
nil
{
if
err
:=
api
.
Run
();
err
!=
nil
{
log
.
WithError
(
err
)
.
Error
(
"api service exit"
)
log
.
WithError
(
err
)
.
Error
(
"api service exit"
)
}
}
...
...
openapi/server.go
View file @
44421f0d
...
@@ -4,14 +4,16 @@ import (
...
@@ -4,14 +4,16 @@ import (
"fmt"
"fmt"
"github.com/gin-gonic/gin"
"github.com/gin-gonic/gin"
log
"github.com/sirupsen/logrus"
log
"github.com/sirupsen/logrus"
"github.com/xueqianlu/caddyproxy/caddy"
)
)
type
OpenAPI
struct
{
type
OpenAPI
struct
{
conf
*
Config
conf
*
Config
caddyapi
*
caddy
.
CaddyAPI
}
}
func
NewOpenAPI
(
conf
*
Config
)
*
OpenAPI
{
func
NewOpenAPI
(
conf
*
Config
,
capi
*
caddy
.
CaddyAPI
)
*
OpenAPI
{
return
&
OpenAPI
{
conf
:
conf
}
return
&
OpenAPI
{
conf
:
conf
,
caddyapi
:
capi
}
}
}
func
(
s
*
OpenAPI
)
Run
()
error
{
func
(
s
*
OpenAPI
)
Run
()
error
{
...
@@ -25,8 +27,8 @@ func (s *OpenAPI) startHttp(address string) error {
...
@@ -25,8 +27,8 @@ func (s *OpenAPI) startHttp(address string) error {
// 创建v1组
// 创建v1组
v1
:=
router
.
Group
(
"/v1"
)
v1
:=
router
.
Group
(
"/v1"
)
{
{
v1
.
POST
(
"/create-website"
,
apiHandler
{}
.
CreateWebsite
)
v1
.
POST
(
"/create-website"
,
apiHandler
{
conf
:
s
.
conf
,
backend
:
s
.
caddyapi
}
.
CreateWebsite
)
v1
.
POST
(
"/forward-website"
,
apiHandler
{}
.
ForwardWebsite
)
v1
.
POST
(
"/forward-website"
,
apiHandler
{
conf
:
s
.
conf
,
backend
:
s
.
caddyapi
}
.
ForwardWebsite
)
}
}
return
router
.
Run
(
address
)
return
router
.
Run
(
address
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment