// Copyright 2022 CloudWeGo Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package tpl

// HandlerMethodsTpl is the template for generating methods in handler.go.
var HandlerMethodsTpl string = `{{define "HandlerMethod"}}
{{range .AllMethods}}
{{- if or .ClientStreaming .ServerStreaming}}
func (s *{{$.ServiceName}}Impl) {{.Name}}({{if $.StreamX}}ctx context.Context, {{end}}{{if not .ClientStreaming}}{{range .Args}}{{LowerFirst .Name}} {{.Type}}, {{end}}{{end}}stream {{.PkgRefName}}.{{.ServiceName}}_{{.RawName}}Server) (err error) {	
	println("{{.Name}} called")
	return
}
{{- else}}
{{- if .Void}}
// {{.Name}} implements the {{.ServiceName}}Impl interface.
{{- if .Oneway}}
// Oneway methods are not guaranteed to receive 100% of the requests sent by the client.
// And the client may not perceive the loss of requests due to network packet loss.
// If possible, do not use oneway methods.
{{- end}}
func (s *{{$.ServiceName}}Impl) {{.Name}}(ctx context.Context {{- range .Args}}, {{LowerFirst .Name}} {{.Type}}{{end}}) (err error) {
	// TODO: Your code here...
	return
}
{{else -}}
// {{.Name}} implements the {{.ServiceName}}Impl interface.
func (s *{{$.ServiceName}}Impl) {{.Name}}(ctx context.Context {{range .Args}}, {{LowerFirst .Name}} {{.Type}}{{end}} ) (resp {{.Resp.Type}}, err error) {
	// TODO: Your code here...
	return
}
{{end}}
{{end}}
{{end}}
{{end}}{{/* define "HandlerMethod" */}}
`
