@@ -2,9 +2,7 @@ package main
22
33import (
44 "fmt"
5- "github.com/example/httpservice/bindings"
65 "log"
7- "net/http"
86 "time"
97)
108
@@ -21,7 +19,7 @@ func NewServiceImpl() *ServiceImpl {
2119 }
2220}
2321
24- func (s * ServiceImpl ) HandleRequest (request bindings. HttpRequest ) bindings. HttpResponse {
22+ func (s * ServiceImpl ) HandleRequest (request HttpRequest ) HttpResponse {
2523 s .requests ++
2624
2725 log .Printf ("Handling %s request to %s" , request .Method , request .Path )
@@ -39,14 +37,14 @@ func (s *ServiceImpl) HandleRequest(request bindings.HttpRequest) bindings.HttpR
3937 }
4038}
4139
42- func (s * ServiceImpl ) handleRoot (request bindings. HttpRequest ) bindings. HttpResponse {
40+ func (s * ServiceImpl ) handleRoot (request HttpRequest ) HttpResponse {
4341 body := `{
4442 "message": "Welcome to Go WebAssembly HTTP Service",
4543 "version": "1.0.0",
4644 "timestamp": "` + time .Now ().Format (time .RFC3339 ) + `"
4745 }`
4846
49- return bindings. HttpResponse {
47+ return HttpResponse {
5048 Status : 200 ,
5149 Headers : map [string ]string {
5250 "Content-Type" : "application/json" ,
@@ -56,7 +54,7 @@ func (s *ServiceImpl) handleRoot(request bindings.HttpRequest) bindings.HttpResp
5654 }
5755}
5856
59- func (s * ServiceImpl ) handleHealth (request bindings. HttpRequest ) bindings. HttpResponse {
57+ func (s * ServiceImpl ) handleHealth (request HttpRequest ) HttpResponse {
6058 uptime := time .Since (s .startTime )
6159
6260 body := fmt .Sprintf (`{
@@ -65,7 +63,7 @@ func (s *ServiceImpl) handleHealth(request bindings.HttpRequest) bindings.HttpRe
6563 "requests_served": %d
6664 }` , uptime .Seconds (), s .requests )
6765
68- return bindings. HttpResponse {
66+ return HttpResponse {
6967 Status : 200 ,
7068 Headers : map [string ]string {
7169 "Content-Type" : "application/json" ,
@@ -74,7 +72,7 @@ func (s *ServiceImpl) handleHealth(request bindings.HttpRequest) bindings.HttpRe
7472 }
7573}
7674
77- func (s * ServiceImpl ) handleStats (request bindings. HttpRequest ) bindings. HttpResponse {
75+ func (s * ServiceImpl ) handleStats (request HttpRequest ) HttpResponse {
7876 uptime := time .Since (s .startTime )
7977
8078 body := fmt .Sprintf (`{
@@ -97,7 +95,7 @@ func (s *ServiceImpl) handleStats(request bindings.HttpRequest) bindings.HttpRes
9795 s .startTime .Format (time .RFC3339 ),
9896 )
9997
100- return bindings. HttpResponse {
98+ return HttpResponse {
10199 Status : 200 ,
102100 Headers : map [string ]string {
103101 "Content-Type" : "application/json" ,
@@ -106,14 +104,14 @@ func (s *ServiceImpl) handleStats(request bindings.HttpRequest) bindings.HttpRes
106104 }
107105}
108106
109- func (s * ServiceImpl ) handleNotFound (request bindings. HttpRequest ) bindings. HttpResponse {
107+ func (s * ServiceImpl ) handleNotFound (request HttpRequest ) HttpResponse {
110108 body := fmt .Sprintf (`{
111109 "error": "Not Found",
112110 "message": "Path '%s' not found",
113111 "available_paths": ["/", "/health", "/stats"]
114112 }` , request .Path )
115113
116- return bindings. HttpResponse {
114+ return HttpResponse {
117115 Status : 404 ,
118116 Headers : map [string ]string {
119117 "Content-Type" : "application/json" ,
@@ -122,10 +120,10 @@ func (s *ServiceImpl) handleNotFound(request bindings.HttpRequest) bindings.Http
122120 }
123121}
124122
125- func (s * ServiceImpl ) GetServiceInfo () bindings. ServiceInfo {
123+ func (s * ServiceImpl ) GetServiceInfo () ServiceInfo {
126124 uptime := time .Since (s .startTime )
127125
128- return bindings. ServiceInfo {
126+ return ServiceInfo {
129127 Name : "Go WebAssembly HTTP Service" ,
130128 Version : "1.0.0" ,
131129 Description : "A sample HTTP service built as a WebAssembly component using Go" ,
@@ -139,7 +137,7 @@ func main() {
139137 service := NewServiceImpl ()
140138
141139 // Initialize the component with our service implementation
142- bindings . SetExports (service )
140+ SetExports (service )
143141
144142 log .Println ("Go WebAssembly HTTP Service component initialized" )
145143}
0 commit comments