Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions _example/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import (
"fmt"
"os"

"go.osspkg.com/logx"
"go.osspkg.com/xc"

"go.osspkg.com/goppy/v3"
"go.osspkg.com/goppy/v3/console"
"go.osspkg.com/goppy/v3/dic/broker"
"go.osspkg.com/goppy/v3/metrics"
"go.osspkg.com/goppy/v3/plugins"
"go.osspkg.com/goppy/v3/web"
"go.osspkg.com/logx"
"go.osspkg.com/xc"
)

type IStatus interface {
Expand Down
2 changes: 1 addition & 1 deletion _example/go-gen/empty.go → _example/orm-gen/empty.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Use of this source code is governed by a BSD 3-Clause license that can be found in the LICENSE file.
*/

package go_gen
package orm_gen

type Empty struct {
A string
Expand Down
2 changes: 1 addition & 1 deletion _example/go-gen/model.go → _example/orm-gen/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Use of this source code is governed by a BSD 3-Clause license that can be found in the LICENSE file.
*/

package go_gen
package orm_gen

import (
"time"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions _example/web-server-gen/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
SHELL=/bin/bash

run:
go generate -run easyjson ./transport
go run main.go --config=config.yaml

17 changes: 17 additions & 0 deletions _example/web-server-gen/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
env: dev

log:
file_path: /dev/stdout
format: json
level: 4

http:
- tag: main
addr: 0.0.0.0:10000

metrics:
addr: 0.0.0.0:12000
gauge:
- users_request

custom:
71 changes: 71 additions & 0 deletions _example/web-server-gen/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright (c) 2022-2026 Mikhail Knyazhev <markus621@yandex.com>. All rights reserved.
* Use of this source code is governed by a BSD 3-Clause license that can be found in the LICENSE file.
*/

package main

import (
"context"
"fmt"

"go.osspkg.com/goppy/v3"
"go.osspkg.com/goppy/v3/_example/web-server-gen/transport"
"go.osspkg.com/goppy/v3/_example/web-server-gen/types"
"go.osspkg.com/goppy/v3/web"
)

func main() {
// Specify the path to the config via the argument: `--config`.
// Specify the path to the pidfile via the argument: `--pid`.
app := goppy.New("app_name", "v1.0.0", "app description")
app.Plugins(
web.WithServer(),
)
app.Plugins(
NewController,
func(routes web.ServerPool, c *Controller) *transport.JSONRPCHandler {
return transport.NewJSONRPCHandler(routes, c, c, c)
},
)
app.Run()
}

type Controller struct{}

func NewController() *Controller {
return &Controller{}
}

func (c Controller) Name(ctx context.Context, userID int64) (name string, err error) {
//TODO implement me
panic("implement me")
}

func (c Controller) ByID(ctx context.Context, ID int64) (text bool, err error) {
//TODO implement me
panic("implement me")
}

func (c Controller) List(ctx context.Context, userID int64) (text []types.Text, err error) {
//TODO implement me
panic("implement me")
}

func (c Controller) Root(ctx context.Context, userID int64, userName string) (status bool, err error) {
switch userID {
case 0:
return false, fmt.Errorf("userID 0")
default:
return true, nil
}
}

func (c Controller) Auth(ctx context.Context, userID int64, userName string) (status bool, err error) {
switch userID {
case 0:
return false, fmt.Errorf("userID 0")
default:
return true, nil
}
}
23 changes: 23 additions & 0 deletions _example/web-server-gen/test.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
###
POST http://127.0.0.1:10000/rpc
Content-Type: application/json
Cookie: x-user-id=1
x-user-id: 1

[
{
"id": "1",
"method":"api.root",
"params": {
"userName": "xxxx"
}
},
{
"id": "2",
"method":"api.auth",
"params": {
"userName": "xxxx"
}
}
]

149 changes: 149 additions & 0 deletions _example/web-server-gen/transport/jsonrpc_handler.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions _example/web-server-gen/transport/jsonrpc_model.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading