Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a health check feature #275

Closed
k33g opened this issue Jun 8, 2023 · 3 comments · Fixed by #279
Closed

Add a health check feature #275

k33g opened this issue Jun 8, 2023 · 3 comments · Fixed by #279
Assignees
Labels

Comments

@k33g
Copy link
Contributor

k33g commented Jun 8, 2023

  • for capsule http
  • and if a function health exists in the wasm module => probably something to add to the MDK

Related issues:

@k33g k33g added enhancement New feature or request capsule HTTP 0.4.0 labels Jun 8, 2023
@k33g k33g self-assigned this Jun 8, 2023
@k33g
Copy link
Contributor Author

k33g commented Jun 10, 2023

func main() {
	capsule.SetHandleHTTP(func (param capsule.HTTPRequest) (capsule.HTTPResponse, error) {
		
	})

	capsule.SetHandleHealthCheck(func (param capsule.HTTPRequest) (capsule.HTTPResponse, error) {
		
	})
}

@k33g
Copy link
Contributor Author

k33g commented Jun 10, 2023

@k33g
Copy link
Contributor Author

k33g commented Jun 11, 2023

func main() {
	capsule.SetHandleHTTP(func (param capsule.HTTPRequest) (capsule.HTTPResponse, error) {
		
	})

	capsule.SetHandleHealthCheck(func (param capsule.HTTPRequest) (capsule.HTTPResponse, error) {
		
	})
}

other solution: call exported function

//export OnHealthCheck
func OnHealthCheck() uint64 {
	capsule.Print("⛑️ OnHealthCheck")

	response := capsule.HTTPResponse{
		JSONBody: `{"message": "OK"}`,
		Headers: `{"Content-Type": "application/json; charset=utf-8"}`,
		StatusCode: 200,
	}

	return capsule.Success([]byte(capsule.StringifyHTTPResponse(response)))
}

@k33g k33g linked a pull request Jun 11, 2023 that will close this issue
@k33g k33g closed this as completed in #279 Jun 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant