Comments (7)
Hey @da-na, the internal numbers do not have anything to do with what port the connection comes in on. Can you paste your routes here?
from kitura-net.
@dfirsht: I had the same confusion as @da-na. My expectation was the same and I was surprised to see the accepted connection display a different port number for each request. I imagine if I was running a server on multiple ports that it would be more helpful to see the log telling me which of those ports was coming in to, i.e: 80 vs 443. What would be the advantage of the way that it currently is now?
from kitura-net.
@da-na @chrisozenne I have fixed the log message to prevent the confusion - the printed port is the client port, it is not the a server port on which the application accepts incoming connections.
For more about local/remote ports and sockets, see this Stackoverflow answer
from kitura-net.
Thank you!!
from kitura-net.
Thanks for fixing the log!
@dfirsht is there an easy way to print them out ? Like print(router.debugDescription) ? I'm asking as I didn't see it in the code, but maybe I'm missing sth. In case there's none .debugDescription it would be great if you could add it! Same thing for the request.debugDescription
, as currently this Log.info("Request: \(request)")
prints no valuable information.
I set them up this way:
func setupRoutes(router: Router, messages: MessagesArray) {
Log.info("SETTING UP ROUTER")
router.use("/*", middleware: BodyParser())
router.all("/") {
_, _, next in next()
}
// Get all the messages
router.get("/") {
request, response, next in
Log.info("Request: \(request)")
let json = JSON(MessagesArray.serialize(messages.getAll()))
response.status(HttpStatusCode.OK).sendJson(json)
next()
}
// Handle options
router.options("/*") {
request, response, next in
response.setHeader("Access-Control-Allow-Headers", value: "accept, content-type")
response.setHeader("Access-Control-Allow-Methods", value: "GET")
response.status(HttpStatusCode.OK)
Log.info("Options handling set")
next()
}
}
EDIT:
I've add Log.info to the serialize function, and in my code I get this log:
SERIALIZE: [["title": Blabla, "completed": 0, "id": 0, "text": n test, "date_created": 2016-03-15 14:08:23 +0000, "url": http://localhost:8090/messages/0, "originator": Me], ["title": Blabla, "completed": 0, "id": 1, "text": m test, "date_created": 2016-03-15 14:08:23 +0000, "url": http://localhost:8090/messages/1, "originator": Me]]
and then in the browser I get Json Unknown
for the original TodoList the log looks like this
SERIALIZE [["title": Reticulate splines, "completed": 0, "id": 0, "order": 0, "url": http://localhost:8090/todos/0], ["title": Herd llamas, "completed": 0, "id": 1, "order": 1, "url": http://localhost:8090/todos/1]]
and it produces
[
{
"title" : "Reticulate splines",
"completed" : false,
"id" : "0",
"order" : 0,
"url" : "http:\/\/localhost:8090\/todos\/0"
},
{
"title" : "Herd llamas",
"completed" : false,
"id" : "1",
"order" : 1,
"url" : "http:\/\/localhost:8090\/todos\/1"
}
]
Could NSDate be a problem? Or maybe the enum that I'm using for the originator? (It's an enum that inherits after String though)
from kitura-net.
Hi!
The solution is described here: SwiftyJSON/SwiftyJSON#421 (using the NSDate) and is not related to routing.
Thanks for all the help!
Would be awesome though if the *.debugDescription was added :)
from kitura-net.
Great! I'm going to close this then. Yeah I think a debug mode would help, that's something I would like to do in the future.
from kitura-net.
Related Issues (20)
- Implement test for ServerLifecycleListener.performClientConnectionFailCallbacks
- EXC_BAD_ACCESS when reading HTTPServerRequest.method with SwiftMetricsKitura HOT 4
- EXC_BAD_INSTRUCTION on IncomingSocketHandler.swift line 197 (only Mac OS X) HOT 7
- missing required modules: 'CCurl', 'CHTTPParser' HOT 1
- Undeprecate `urlComponents`?
- Thread sanitizer finds issues HOT 7
- Errors in removeIdleSockets HOT 8
- PATCH Request not passing Body HOT 16
- Valid port numbers not representable HOT 6
- Use ephemeral ports in KituraNet tests HOT 1
- Port Kitura Request/Response tests to Kitura-net HOT 1
- Kitura-net ignores an Expect: 100-continue header HOT 1
- Validate curl 7.59 fix for chunked encoding HOT 2
- HTTPStatusCode enum is missing registered values HOT 1
- Gracefully close connections on server shutdown
- Study: Does the HTTP smuggling attack affect Kitura-net?
- ClientRequest error. on Linux HOT 2
- Error=Parsed fewer bytes than were passed to the HTTP parser HOT 5
- How make unix domain sock http req
- Update for Swift 5.2 needed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kitura-net.