mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 02:31:04 +01:00
add a code snippet as a very simplistic overview and update the license dates from 2017 to 2017-2018
Former-commit-id: 1114ea5a38d0f8cf71c808f9603acf05419ecd4d
This commit is contained in:
parent
85f179602d
commit
05334560f3
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2017 The Iris Authors. All rights reserved.
|
||||
Copyright (c) 2017-2018 The Iris Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
|
|
67
README.md
67
README.md
|
@ -1,4 +1,4 @@
|
|||
# Iris web framework
|
||||
# Iris Web Framework
|
||||
|
||||
<img align="right" width="170px" src="https://iris-go.com/images/icon.svg?v=10" title="logo created by @merry.dii" />
|
||||
|
||||
|
@ -18,6 +18,71 @@ Thank you to all our backers! [Become a backer](https://opencollective.com/iris#
|
|||
|
||||
<a href="https://opencollective.com/iris#backers" target="_blank"><img src="https://opencollective.com/iris/backers.svg?width=890"></a>
|
||||
|
||||
```sh
|
||||
$ cat example.go
|
||||
```
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import "github.com/kataras/iris"
|
||||
|
||||
func main() {
|
||||
app := iris.New()
|
||||
// Load all templates from the "./views" folder
|
||||
// where extension is ".html" and parse them
|
||||
// using the standard `html/template` package.
|
||||
app.RegisterView(iris.HTML("./views", ".html"))
|
||||
|
||||
// Method: GET
|
||||
// Resource: http://localhost:8080
|
||||
app.Get("/", func(ctx iris.Context) {
|
||||
// Bind: {{.message}} with "Hello world!"
|
||||
ctx.ViewData("message", "Hello world!")
|
||||
// Render template file: ./views/hello.html
|
||||
ctx.View("hello.html")
|
||||
})
|
||||
|
||||
// Method: GET
|
||||
// Resource: http://localhost:8080/user/42
|
||||
//
|
||||
// Need to use a custom regexp instead?
|
||||
// Easy,
|
||||
// just mark the parameter's type to 'string'
|
||||
// which accepts anything and make use of
|
||||
// its `regexp` macro function, i.e:
|
||||
// app.Get("/user/{id:string regexp(^[0-9]+$)}")
|
||||
app.Get("/user/{id:long}", func(ctx iris.Context) {
|
||||
userID, _ := ctx.Params().GetInt64("id")
|
||||
ctx.Writef("User ID: %d", userID)
|
||||
})
|
||||
|
||||
// Start the server using a network address.
|
||||
app.Run(iris.Addr(":8080"))
|
||||
}
|
||||
```
|
||||
|
||||
> Learn more about path parameter's types by clicking [here](_examples/routing/dynamic-path/main.go#L31)
|
||||
|
||||
```html
|
||||
<!-- file: ./views/hello.html -->
|
||||
<html>
|
||||
<head>
|
||||
<title>Hello Page</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>{{.message}}</h1>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
```sh
|
||||
$ go run example.go
|
||||
Now listening on: http://localhost:8080
|
||||
Application Started. Press CTRL+C to shut down.
|
||||
_
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
The only requirement is the [Go Programming Language](https://golang.org/dl/)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2017 The Iris Sessions Authors. All rights reserved.
|
||||
Copyright (c) 2017-2018 The Iris Sessions Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2017 The Iris Typescript Authors. All rights reserved.
|
||||
Copyright (c) 2017-2018 The Iris Typescript Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
Copyright (c) 2017 The Iris Websocket Authors. All rights reserved.
|
||||
Copyright (c) 2017-2018 The Iris Websocket Authors. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
|
|
Loading…
Reference in New Issue
Block a user