Add a hypothetical Echo example
This commit is contained in:
parent
646bb624db
commit
46e89084bf
26
examples/echo/echo.mu
Normal file
26
examples/echo/echo.mu
Normal file
|
@ -0,0 +1,26 @@
|
|||
// Copyright 2016 Marapongo, Inc. All rights reserved.
|
||||
|
||||
module echo
|
||||
import mu
|
||||
|
||||
// Echo is a simple service that wraps an API gateway and exposes a single Say function.
|
||||
service Echo {
|
||||
ctor() {
|
||||
new mu.APIGateway {
|
||||
api = this
|
||||
impl = "./mu.ts"
|
||||
port = this.properties.port
|
||||
}
|
||||
}
|
||||
|
||||
interface {
|
||||
// Say simply echoes back the given string.
|
||||
Say(s: string): string
|
||||
}
|
||||
|
||||
properties {
|
||||
// port is an optional port number for the API service.
|
||||
optional port: number = 80
|
||||
}
|
||||
}
|
||||
|
23
examples/echo/echo.ts
Normal file
23
examples/echo/echo.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
// Copyright 2016 Marapongo, Inc. All rights reserved.
|
||||
|
||||
import * as mu from 'mu';
|
||||
|
||||
// Echo is a simple service that wraps an API gateway and exposes a single Say function.
|
||||
class Echo extends mu.Service {
|
||||
constructor(
|
||||
// port is an optional port number for the API service.
|
||||
port: number = 80
|
||||
) {
|
||||
new mu.APIGateway({
|
||||
api: this
|
||||
port: port
|
||||
});
|
||||
}
|
||||
|
||||
// Say simply echoes back the given string.
|
||||
@mu.api()
|
||||
public Say(s: string): string {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in a new issue