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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: actions/checkout@v3
- name: Install webrpc-gen
run: |
curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.18.6/webrpc-gen.linux-amd64
curl -o ./webrpc-gen -fLJO https://github.com/webrpc/webrpc/releases/download/v0.32.3/webrpc-gen.linux-amd64
chmod +x ./webrpc-gen
echo $PWD >> $GITHUB_PATH

Expand Down
6 changes: 3 additions & 3 deletions _examples/hello-webrpc/webapp/client.gen.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// hello-webrpc v1.0.0 4fc01b139e8de5a1eb11b0581cd706326a434708
// hello-webrpc v1.0.0 7037367a376940060eaf2739a920c4dca4a6dc2e
// --
// Code generated by webrpc-gen@v0.18.6 with ../../ generator. DO NOT EDIT.
// Code generated by webrpc-gen@v0.32.3 with ../../ generator. DO NOT EDIT.
//
// webrpc-gen -schema=hello-api.ridl -target=../../ -exports=false -client -out=./webapp/client.gen.js

Expand All @@ -11,7 +11,7 @@ const WebRPCVersion = "v1"
const WebRPCSchemaVersion = "v1.0.0"

// Schema hash generated from your RIDL schema
const WebRPCSchemaHash = "4fc01b139e8de5a1eb11b0581cd706326a434708"
const WebRPCSchemaHash = "7037367a376940060eaf2739a920c4dca4a6dc2e"

//
// Types
Expand Down
8 changes: 5 additions & 3 deletions client.go.tmpl
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
{{define "client"}}

{{- $basepath := .BasePath -}}
{{- $services := .Services -}}
{{- $opts := .Opts -}}

{{- if .Services}}
{{- if $services }}
//
// Client
//
{{ range .Services}}
{{ range $services }}
{{if $opts.exports}}export {{end}}class {{.Name}} {
constructor(hostname, fetch) {
this.path = '/rpc/{{.Name}}/'
this.path = '{{$basepath}}{{.Name}}/'
this.hostname = hostname
this.fetch = (input, init) => fetch(input, init)
}
Expand Down
4 changes: 2 additions & 2 deletions main.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@

{{template "types" dict "Services" .Services "Types" .Types "Opts" $opts}}
{{- if $opts.client}}
{{template "client" dict "Services" .Services "Opts" $opts}}
{{template "client" dict "BasePath" .BasePath "Services" .Services "Opts" $opts}}
{{template "client_helpers" .}}
{{- end}}
{{- if $opts.server}}
{{template "server" dict "Services" .Services "Opts" $opts "TypeMap" $typeMap}}
{{template "server" dict "BasePath" .BasePath "Services" .Services "Opts" $opts "TypeMap" $typeMap}}
{{- end}}
{{- end}}
3 changes: 2 additions & 1 deletion server.go.tmpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{{define "server"}}

{{- $basepath := .Basepath -}}
{{- $services := .Services -}}
{{- $typeMap := .TypeMap -}}

Expand Down Expand Up @@ -37,7 +38,7 @@ import express from 'express'
switch(requestPath) {
{{range $_, $method := $service.Methods}}

case "/rpc/{{$service.Name}}/{{$method.Name}}": {
case "{{$basepath}}{{$service.Name}}/{{$method.Name}}": {
try {
{{ range $_, $input := $method.Inputs }}
{{- if not $input.Optional}}
Expand Down
2 changes: 1 addition & 1 deletion tests/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class Complex {

export class TestApi {
constructor(hostname, fetch) {
this.path = '/rpc/TestApi/'
this.path = '/v1/TestApi/'
this.hostname = hostname
this.fetch = () => fetch
}
Expand Down